很简单:PowerShell脚本只能运行在PowerShell中,而不是作为参数传递给powershell.exe
> powershell.exe -command "& '\\RemoteServer\c$\My Script.ps1'"
不会在所有的工作。在记事本中打开My Script.ps1
,仅此而已。同时,
> powershell
PS > &"\\RemoteServer\c$\My Script.ps1"
工作得很好(脚本执行)。
我不得不使用caspol
工具,因为我的脚本依赖于二进制模块,但我不明白这可能是什么问题。
对这个问题的原因有什么想法?
谢谢!