免责声明:我不是DevOps家伙,所以请原谅任何无知。我正在学习这些东西,以加深我的理解。
我已在Windows Server 2019实例上启用了远程Powershell,以便在从构建服务器(也是Windows Server 2019)部署文件期间停止/启动计划的任务。
我以远程服务器上的Adminstrator
用户身份在Administrator Powershell中执行了以下步骤:1.启用RSRemoting
。2.删除现有的侦听器。3.创建自签名证书并导出到crt
文件。
$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "<subdomain.domain.com>"
[从构建服务器,我已经在Powershell中使用以下命令测试了配置:
$username = 'Administrator'
$pass = ConvertTo-SecureString -string '<password here>' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
Invoke-Command -ComputerName <subdomain.domain.com> -UseSSL -ScriptBlock {whoami} -Credential $cred
[win-<some stuff>\administrator
的响应很好。但是,当我从TeamCity构建步骤中执行远程Powersehll命令时,会出现一个非常难看的Connecting to remote server <subdomain.domain.com> failed with the following error message : Access is denied.
。
奇怪的是,这是两天前完成的工作,我拥有一些能够完成所有远程操作的构建。从今天早上开始,它刚刚停止工作-of!
如果我篡改了凭据,则会收到错误的用户名/密码错误,因此肯定可以到达服务器。
另一个有趣的发现是,如果我跑步
[bool](Test-WSMan)
在远程服务器上,我得到True
返回,但是如果在构建服务器上用-ComputerName <subdomain.domain.com>
运行相同的命令,我得到WinRM cannot complete the operation. Verify that the specified computer name is
valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits
access to remote computers within the same local subnet.
返回。远程主机和构建服务器均以默认Administrator
身份登录。
有什么想法吗?
[经过更多研究并提出了一些建议后,建议我调整TeamCity Build Agent
和TeamCity Server
服务。这些需要Log On As
和User
而不是Local System
。我无法解释以前的设置如何工作。我遇到的Access is denied
错误与上述远程Powershell配置无关。