Powershell 命令手动工作,但在 Jenkins 中执行时不起作用

Powershell command works manually, but does not work when executed in Jenkins

我有一个奇怪的场景,我的命令在 PowerShell 上手动运行,但在 Jenkins PowerShell 插件上执行时却不行。我是 PowerShell 和 Jenkins 的新手,我认为我缺少一条规则。我找遍了这里和网络,但我没有找到解决方案。

我创建了一个执行 PowerShell 脚本的作业,该脚本使用自由式项目在我的桌面上打开 RDP 文件。它在 Powershell 上执行时按预期工作,但在 Jenkins 中,构建成功但没有打开 RDP。

这是脚本:

Start-Process "$env:windir\system32\mstsc.exe" -ArgumentList "RDP File /h:900 /w:1600" -WindowStyle Minimized

我正在使用 Windows Server 2016。

这是我尝试过的:

  1. 默认情况下 Jenkins 使用 32 位的 PowerShell,所以我手动使用了 64 位的但它不起作用。
  2. 我确保在 LocalMachine 上将 Get-ExecutionPolicy 设置为 RemoteSigned
  3. 运行 脚本使用 Windows 批处理命令
  4. 我尝试打开记事本,但它也不起作用。

这真的是 PowerShell 插件的行为吗?有什么我想念的吗?请帮我解决这个问题。

任何人都可能需要这个。我能够通过 Jenkins PowerShell 插件执行 RDP。

我所做的是转到 Jenkins 的 Window 服务 > 登录选项卡 > Select "This account" 并输入您的用户帐户凭据。

我怀疑这是一个安全问题。 Jenkins 默认使用没有足够权限的 "SYSTEM" 帐户。