0

I am trying to open a protected excel file and re-save it without the password. I created a PowerShell script and it works if I manually set the executionpolicy to remotesigned or unrestricted.

I would like to not enable scripts but just bypass it through SSIS. I have tried a bunch of things the following is what I tried, but it does not work.

EXECUTE PROCESS TASK
Executable: C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
Arguement: -ExecutionPolicy ByPass -File "S:\PowerShell\UnlockExcel.ps1"

I have tried -Command instead of -File as well.

If I run the script after manually enabling scripts in PowerShell the script works so there is nothing wrong with the script, but if I put it back to restricted and try it with those arguments in SSIS it won't work.

5
  • I see S:\, is this a drive that would be available physically for the executing account or is it a mapped drive that a SYSTEM account or Service Account would have present? Commented Mar 1, 2016 at 23:21
  • Yeah its a mapped drive and it is available everywhere. I could try UNC path. I'll get back to you if it works. Commented Mar 2, 2016 at 11:15
  • That didn't work.. I added the unc path instead of S:\.. it gave me a exit code -196608... And so i tried it with -Command instead if -File and that didn't give me anything it didn't bypass just reports success, but actually does nothing I believe it gave the cannot run script. Commented Mar 2, 2016 at 12:17
  • Can you create a simple ps1 script on the local disk that creates some out-file content to confirm the executing line is good, then move onto the UnlockExcel.ps1 file. Additionally I usually format my scheduled task jobs with the following arguments. -NoLogo -NoProfile -ExecutionPolicy Bypass -File Commented Mar 2, 2016 at 17:42
  • Hi can you put your comment as answer so I can tick it as an answer. the -NoLogo -NoProfile -ExecutionPolicy Bypass -File worked.. no idea why it won't work without -NoLogo -NoProfile. Oh well atleast it worked. Commented Mar 11, 2016 at 11:38

2 Answers 2

1

Modify the executing line to include the following format.

-NoLogo -NoProfile -ExecutionPolicy Bypass -File

powershell.exe command line reference TechNet Link

Sign up to request clarification or add additional context in comments.

Comments

0

This worked for me on Windows 2007 machine.I will update my answer when I deploy this on Server 2012 - I am hoping I don't have to reinvent the wheel again. MOre to come...

Executable: %windir%\system32\WindowsPowerShell\v1.0\PowerShell.exe

Arguments: -NoProfile "C:\temp\scripts\vpn.ps1"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.