cmm user
cmm user

Reputation: 2596

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

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"}' 

Upvotes: 2

Views: 19223

Answers (3)

Wim277
Wim277

Reputation: 1

Just installed Exchange 2016 en had the "The WinRM client cannot process the request because the server name cannot be resolved" problem. Removed winhttp proxy setting and BAM!

Upvotes: -1

Glen Buktenica
Glen Buktenica

Reputation: 31

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/

Upvotes: 3

Bryan Oakley
Bryan Oakley

Reputation: 385800

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)?

Upvotes: 5

Related Questions