Powershell remoting with ip-address as target

Viewed 205849

I successfully enabled PSRemoting on my Server 2008 R2. I'm able to do a remote-pssession from within the same network using the hostname as target.

I'm failing when I try to use the IP-Address as target from any computer (within the network or from another network (for example via VPN)). I want to be able to use remoting through my VPN connection where I have to use the IP-Address since the hostname can't be resolved.

I don't want to add names into my hosts-file because there are a few other servers at our clients' that have the same dns-name and I don't want to remove and insert the name-ip-address-association again and again.

I hope someone can tell me how to allow the psremoting-target to be called via IP.

Edit: To be more specific, I want to be able to run this:

Enter-PSSession -Computername 192.168.123.123 -credentials $cred 

But I'm only able to run that command if I pass a hostname to "-Computername"

Edit2:
I'm getting following errormessage when I try to login using the ip instead of the hostname (from the internal network):

Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process
 the request. Default authentication may be used with an IP address under the following conditions: the transport is HT
TPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure T
rustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to se
t TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting
 Help topic.

Edit3:
I know about the trusted-hosts setting of WSMan, but that doesn't seem to be the problem. It is already set to "*" (I did that right after enabling remoting), but I still can't connect to that server using the ip as target-computername, but I'm able to connect using the hostname as target-computername. Seems like there's something like the binding in IIS that prevents the listener to listen on requests that target the ip-number instead of the hostname. But IIS isn't installed. I don't know where to look for such a setting.

Update 2011-07-12:
Okay, I think that trustedhosts-setting is not the problem because I CAN connect from our DC via hostname but not if I use the ip-address of the destination for the computer-param.
I think, the problem must be the listener. Maybe the listener takes no requests that were targeted to the destination-ip instead of the destination-hostname. But I don't know how to change that.

9 Answers

On your machine* run 'Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$ipaddress"

*Machine from where you are running PSSession

On Windows 10 it is important to make sure the WinRM Service is running to invoke the command

* Set-Item wsman:\localhost\Client\TrustedHosts -value '*' -Force *

For those of you who don't care about following arbitrary restriction imposed by Microsoft you can simply add a host file entry to the IP of the server your attempting to connect to rather then use that instead of the IP to bypass this restriction:

Enter-PSSession -Computername NameOfComputerIveAddedToMyHostFile -credentials $cred 

Please try the following on the client:

Run the following command to restore the listener configuration:

winrm invoke Restore winrm/Config

Run the following command to perform a default configuration of the Windows Remote Management service and its listener:

winrm quickconfig

After you configured winrm again, make sure host is trusted:

Set-Item wsman:\localhost\Client\TrustedHosts -value "$ipaddress" -Force 

Try remote connect again

Reference

Configure winrm for HTTPS

I spend a great amount of time and finally got the solution. Following are the steps to do fix this -

  1. Go to Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings in control panel
  2. Make sure machine discovery in domain and guest is ON.
  3. Open powershell in administrator mode on client machine and run winrm quickconfig and winrm set winrm/config/client '@{TrustedHosts="*"}'
Related