SSIS PowerShell Script EXECUTE

大憨熊 提交于 2019-12-12 02:55:37

问题


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.


回答1:


Modify the executing line to include the following format.

-NoLogo -NoProfile -ExecutionPolicy Bypass -File

powershell.exe command line reference TechNet Link




回答2:


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"



来源:https://stackoverflow.com/questions/35729192/ssis-powershell-script-execute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!