【问题标题】:Getting error while trying to invoke a powershell command on a remote machine尝试在远程计算机上调用 powershell 命令时出错
【发布时间】:2018-04-25 16:43:45
【问题描述】:

machineName 已尝试通过以下方式使用 invoke-command 执行脚本:

 Invoke-command -filepath C:\scripts\GettMembers.ps1 -computername "machinename" -credential $Getcredential 

但我收到以下错误:

Connecting to remote server failed with the following error message : The WinRM client cannot process the request because the server name cannot be resolved. For more information, see the about_Remote_Troubleshooting Help topic.

但我可以使用以下命令将机器添加到本地机器的受信任主机:

winrm set winrm/config/client `@{TrustedHosts="machineName"}' 

【问题讨论】:

  • 所以大概你的命令实际上看起来像这样:Invoke-Command -computername madhsubr-lap.idc.oracle.com ...?也就是说,您并没有真正使用“机器名”,对吗? :-) 您是否在 madhsubr-lap.idc.oracle.com 上尝试过 nslookup?
  • 似乎是名称解析 (DNS) 错误。试试nslookup <remotecomputer>
  • 这是一个错误。我使用的是机器名本身,即invoke-command和winrm set命令中使用的机器名是相同的。我尝试在机器上运行 nslook。我收到以下异常:'找不到 machineName: Non-existent domain'

标签: powershell powershell-2.0 invoke powershell-remoting


【解决方案1】:

问题似乎是您的 DNS 不知道如何解决“机器名”。这不是powershell问题,而是系统配置问题。

您可以通过要求 powershell 使用以下内容解析机器名称来验证这一点:

$machine = "machinename"
[System.Net.Dns]::GetHostEntry($machine)

如果您收到错误,则表示您使用的机器名称无法解析(即:Windows 无法将“机器名称”转换为 IP 地址)。这不是信任或权限问题,而是您的计算机认为“machinename”不是您网络上的有效计算机。

您是否尝试过使用完全限定的地址(例如:machinename.mycompany.com)?

【讨论】:

    【解决方案2】:

    我在两台为 DNS 配置且可以 ping 目标的服务器上收到此错误。解决方法是这个命令:

    netsh winhttp 重置代理

    感谢以下博客: http://directaccessguide.com/2014/03/05/winrm-client-errors-in-remote-access-console/

    【讨论】:

    • 虽然完全不可能,但经过几天的试验,这解决了我们的问题!
    【解决方案3】:

    刚安装的 Exchange 2016 遇到“WinRM 客户端无法处理请求,因为无法解析服务器名称”的问题。删除了 winhttp 代理设置和 BAM!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-21
      • 1970-01-01
      • 1970-01-01
      • 2012-04-28
      • 1970-01-01
      • 2021-07-22
      • 2012-02-25
      相关资源
      最近更新 更多