windows - PowerShell:客户端无法连接到请求中指定的目标

标签 windows powershell azure-pipelines

我的目标是通过 TFS 任务在远程服务器上执行 PowerShell 文件'PowerShell on Target Machines '
到目前为止,我采取的步骤是:
构建和远程服务器都已启用

Enable-PSRemoting -Force
还添加了添加的信任主机服务器 IP
Set-Item wsman:\localhost\client\trustedhosts *
Restart-Service WinRM
完成上述所有步骤后,TFS 任务仍然出现以下错误

##[error]Connecting to remote server 'REMOTE SERVER IP' failed with the following error message The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.


将是什么原因或我错过了什么。

最佳答案

以下是错误的一些可能原因和一些故障排除建议:
建议 1
如果 Window 远程管理服务及其监听器功能已损坏,则可能会出现此问题。
要解决此问题,请按照下列步骤操作:
第1步。安装最新的 Windows 远程管理更新。
第2步。运行以下命令恢复监听配置:

winrm invoke Restore winrm/Config
第三步。运行以下命令以执行 Windows 远程管理服务及其监听器的默认配置:
winrm quickconfig
点击this document了解详细信息。
忠告 2
防火墙异常的组策略配置可能不正确。策略中的配置错误导致 ListeningOn 的值为空。属性(property)。使用以下命令检查该值。
PS> Get-WSManInstance winrm/config/listener -Enumerate
点击this document了解详细信息以及如何解决问题。
建议 3
问题的可能原因是 HTTP 代理的错误设置。因为 PowerShell 远程处理使用 HTTP 协议(protocol),所以它受 HTTP 代理设置的影响。
要解决此问题:
第1步。使用 ProxyAccessType , ProxyAuthentication , 和 ProxyCredential New-PSSessionOption 的参数cmdlet 为您的企业创建具有代理设置的 session 选项对象。保存选项对象是一个变量。
第2步。使用包含选项对象的变量作为 SessionOption 的值New-PSSession 的参数, Enter-PSSession , 或 Invoke-Command命令。
点击this document了解详细信息。
建议 4
尝试在本地运行您的 PowerShell 文件,看看它是否有相同的错误。

关于windows - PowerShell:客户端无法连接到请求中指定的目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65108982/

相关文章:

Azure Pipeline 在文件路径中返回 "undefined"

powershell - 如何在Powershell中动态填充用户输入中未知数量的变量?

.net-core - 在 Azure Pipelines 构建中命名生成的 ZIP 存档?

php - Codeigniter 站点仅显示一个包含的 View

windows - 静态链接 openssl 库

c# - 目录搜索器

powershell - 获取本地组 cmdlet 获取本地组 : The term 'Get-LocalGroup' is not recognized as the name of a cmdlet,

android - 将 Android Studio 项目与 Azure Pipelines CI/CD 集成

使用 Visual Studio 创建大小为 100 字节的 C 程序

python - 如何在没有 pythonw.exe 的情况下将 Python 脚本放在后台?