PowerShell脚本执行

PowerShell脚本执行

本文介绍了SSIS PowerShell脚本执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打开一个受保护的excel文件,然后在没有密码的情况下重新保存它.我创建了一个PowerShell脚本,如果我将执行策略手动设置为remotesignedunrestricted,它将可以正常工作.

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.

我不想启用脚本,而只是通过SSIS绕过它.我已经尝试了很多方法,以下是我尝试过的方法,但是它不起作用.

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"

我也尝试过 -Command ,而不是 -File .

如果在PowerShell中手动启用脚本后运行脚本,则脚本可以正常工作,因此脚本没有任何问题,但是,如果我将其放回受限状态并在SSIS中尝试使用这些参数,将无法正常工作.

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.

推荐答案

修改执行行以包括以下格式.

Modify the executing line to include the following format.

-NoLogo -NoProfile -ExecutionPolicy Bypass -File

powershell.exe命令行参考 TechNet链接

powershell.exe command line reference TechNet Link

这篇关于SSIS PowerShell脚本执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 13:36