在启动时执行PS

时间:2016-12-28 18:02:06

标签: powershell

我正在运行.bat文件以在启动时调用PS文件,

Powershell -command "C:\temp\VPNVPNcli_test.ps1"

我收到此错误

C:\temp\VPNVPNcli_test.ps1 : The term 'C:\temp\VPNVPNcli_test.ps1' is not
recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ C:\temp\VPNVPNcli_test.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~

1 个答案:

答案 0 :(得分:3)

-Command用于执行命令,如果要传递脚本文件,则需要使用-File

Powershell.exe -File "C:\temp\VPNVPNcli_test.ps1"

如果您的域中没有一致的执行策略,那么执行executionpolicy旁路可能也是个好主意。