我无法在远程计算机上使用 Invoke-Command 从 C# 执行 Powershell 文件脚本,但同时我可以通过 PowerShell 命令窗口在远程计算机上使用 Invoke-Command 执行相同的脚本文件,而无需任何问题。
通过在两台机器上执行调用 Enable-PsRemoting,我的远程机器和本地机器都启用了远程处理。我还将两台机器上的 ExecutionPolicy 设置为 Unrestricted。
在执行脚本时,我收到以下错误/执行:
File G:\x.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
我不明白这里有什么问题。