Getting error while trying to invoke a powershell command on a remote machine

14,904

Solution 1

The problem appears to be that "machinename" isn't something your DNS knows how to resolve. This isn't a powershell problem, but rather a system configuration problem.

You can verify this by asking powershell to resolve the machine name with something like this:

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

If you get an error, that means that you're using a machine name that can't be resolved (ie: windows can't convert "machinename" to an IP address). It's not a matter of trust or permissions, it's that your computer doesn't think "machinename" is a valid machine on your network.

Have you tried using a fully qualified address (eg: machinename.mycompany.com)?

Solution 2

I was getting this error on two servers that were configured for DNS and could ping the target. The resolution was this command:

netsh winhttp reset proxy

Credit to the following blog: http://directaccessguide.com/2014/03/05/winrm-client-errors-in-remote-access-console/

Share:
14,904
cmm user
Author by

cmm user

Graduate Student at Texas A & M university in MS CE. Previously worked as a software developer in Oracle India Private limited for the past 3 years. Currently working as a Software Development Engineer with Amazon Alexa.

Updated on June 14, 2022

Comments

  • cmm user
    cmm user almost 2 years

    machineName have tried executing a script using invoke-command in the following way:

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

    But I am getting the following error :

    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.
    

    But I was able to add the machine to the trusted hosts of the local machine using the following command :

    winrm set winrm/config/client `@{TrustedHosts="machineName"}' 
    
  • nullp01nter
    nullp01nter over 4 years
    Although completely unlikely, this saved our problem after days of experimenting!