PowerShell 远程调用。访问被拒绝
为了自动化测试发布,我需要访问其他域组中的远程计算机。 我在远程计算机上所做的操作:
- 运行 Enable-PSRemoting
- set TrustedHosts "*"
- 添加了带有自签名证书的 https 侦听器,
- 打开了 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:
- run Enable-PSRemoting
- set TrustedHosts "*"
- added https listener with self-signed certificate
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了问题,当我将 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.