我正在运行.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
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
答案 0 :(得分:3)
-Command
用于执行命令,如果要传递脚本文件,则需要使用-File
Powershell.exe -File "C:\temp\VPNVPNcli_test.ps1"
如果您的域中没有一致的执行策略,那么执行executionpolicy旁路可能也是个好主意。