none
The WinRM client cannot complete th e operation

    Question

  • Hi,

    I am running this code to stop a service on a remote server.

    $username = ConvertTo-SecureString username -AsPlainText -Force
    $password = ConvertTo-SecureString password -AsPlainText -Force
    $cred = new-object management.automation.pscredential $username,$password

    Invoke-Command -ComputerName TEST130 -ScriptBlock{net stop SNMP} -Credential $cred

    However I get the error

    [TEST130] Connecting to remote server failed with the following error message : The WinRM client cannot complete th
    e operation within the time specified. Check if the machine name is valid and is reachable over the network and firewal
    l exception for Windows Remote Management service is enabled. For more information, see the about_Remote_Troubleshootin
    g Help topic.
        + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException
        + FullyQualifiedErrorId : PSSessionStateBroken

    I am able to ping the remote server using DNS name and I also ran the WINRM enable command on the remote server. I have been struggling with this for quite sometime. I will appreciate any help on this.

    Saturday, September 28, 2013 4:49 PM

Answers

  • Well, if you weren't listening on port 5985 before, you are now.  Other than an IP routing problem or a firewall blocking the traffic, I can't think of any other reason you'd be getting the PSRemotingTransportException.  Just to make sure everything's working properly, you can download PortQry from http://www.microsoft.com/en-ca/download/confirmation.aspx?id=17148 onto the client computer, extract it and run this command:

    portqry -n 10.100.10.119 -e 5985 -p tcp -nr

    You should get a status of LISTENING, if everything is set up properly.  If it says FILTERED, you've got a firewall blocking traffic somewhere, most likely.

    Sunday, September 29, 2013 12:17 AM

All replies

  • Make sure any firewalls (including Windows Firewall) are allowing traffic on TCP port 5985.

    Saturday, September 28, 2013 5:40 PM
  • All TCP and UDP ports are allowed bidirectional on both the local and remote system. The local system is on Windows 2003 and remote system is on Windows 2008
    Saturday, September 28, 2013 5:59 PM
  • Try running winrm enumerate winrm/config/listener on the Windows 2003 machine.  It's possible that it's configured with the old default port of 80 instead of 5985.  If that's the case, just add -Port 80 to your Invoke-Command parameters when connecting to this computer, or even better, update the listener to use the new default port of 5985:

    # If you're executing this from a PowerShell v2 prompt, type it like this:
    
    winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'
    
    # From cmd.exe, it's the same, except without the single quotes:
    
    winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}

    Saturday, September 28, 2013 7:25 PM
  • Hi David,

    I get the following. I addedto the script and that did not work.

    winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'

    PS C:\Users\kn857ar> winrm enumerate winrm/config/listener
    Listener
        Address = *
        Transport = HTTP
        Port = 5985
        Hostname
        Enabled = true
        URLPrefix = wsman
        CertificateThumbprint
        ListeningOn = 10.100.10.119, 127.0.0.1, ::1, fe80::100:7f:fffe%12, fe80::5efe:10.100.10.119%14

    Saturday, September 28, 2013 7:35 PM
  • Well, if you weren't listening on port 5985 before, you are now.  Other than an IP routing problem or a firewall blocking the traffic, I can't think of any other reason you'd be getting the PSRemotingTransportException.  Just to make sure everything's working properly, you can download PortQry from http://www.microsoft.com/en-ca/download/confirmation.aspx?id=17148 onto the client computer, extract it and run this command:

    portqry -n 10.100.10.119 -e 5985 -p tcp -nr

    You should get a status of LISTENING, if everything is set up properly.  If it says FILTERED, you've got a firewall blocking traffic somewhere, most likely.

    Sunday, September 29, 2013 12:17 AM