【问题标题】:Not able to execute the Power shell script from C# with Invoke-Command on a remote machine无法在远程计算机上使用 Invoke-Command 从 C# 执行 Powershell 脚本
【发布时间】:2013-12-18 20:50:47
【问题描述】:

我无法在远程计算机上使用 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.

我不明白这里有什么问题。

【问题讨论】:

    标签: powershell scripting invoke-command


    【解决方案1】:

    这台机器是否运行 64 位操作系统?如果是,则将同时存在 32 位和 64 位 PowerShell 环境,并且每个环境都有自己的执行策略。根据您调用脚本的方式,您可能不会在与您在命令窗口中交互使用的环境和执行策略相同的环境和执行策略中运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多