PowerShell 远程调用。访问被拒绝

发布于 2024-12-03 04:21:09 字数 908 浏览 2 评论 0原文

为了自动化测试发布,我需要访问其他域组中的远程计算机。 我在远程计算机上所做的操作:

  1. 运行 Enable-PSRemoting
  2. set TrustedHosts "*"
  3. 添加了带有自签名证书的 https 侦听器,
  4. 打开了 5985 和 5986 端口

现在脚本已通过 PowerShell 控制台成功运行。 但是,当我尝试通过 TeamCity 代理运行远程脚本时,我收到以下错误:

Connecting to remote server failed with the following error message :
Access is denied. For more information, see the
about_Remote_Troubleshooting Help topic.

TeamCity 代理服务正在使用本地系统权限运行。

会话初始化

$password = ConvertTo-SecureString $appServerPwd -AsPlainText -Force 
$appCred = New-Object System.Management.Automation.PsCredential($appServerUser,$password)
$rs = New-PSSession -ComputerName $appServer -Credential $appCred -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -Authentication Negotiate

此外,当我尝试通过 TeamCity 远程调用域计算机时,一切正常。 您知道如何解决这个问题吗?

迪马

In order to automate test releases, I need access to remote computer in other domain group.
What I've done on remote computer:

  1. run Enable-PSRemoting
  2. set TrustedHosts "*"
  3. added https listener with self-signed certificate
  4. opened 5985 and 5986 ports

So now scripts are running successfuly via PowerShell console.
But when I'm trying to run remote script via TeamCity agent I've been receiving following error:

Connecting to remote server failed with the following error message :
Access is denied. For more information, see the
about_Remote_Troubleshooting Help topic.

TeamCity agent service is running with Local System rights.

Session initialization

$password = ConvertTo-SecureString $appServerPwd -AsPlainText -Force 
$appCred = New-Object System.Management.Automation.PsCredential($appServerUser,$password)
$rs = New-PSSession -ComputerName $appServer -Credential $appCred -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -Authentication Negotiate

Also when I'm trying to make remote call to domain computer via TeamCity everything works.
Do you have any idea how to solve this issue ?

Dima

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分分钟 2024-12-10 04:21:09

我发现了问题,当我将 TeamCity 代理服务上的“本地系统”用户更改为管理员用户时,一切都开始工作。
因此,问题在于“本地系统”和管理员之间的权利(启动 PSSesion)。

I've found the problem, as soon I changed "Local System" user to Administrator user on TeamCity agent service, everything started to work.
So the issues was in rights (starting PSSesion) between "Local System" and Administrator.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文