Author Posts

June 7, 2016 at 8:52 pm

Hello guys,

I wrote a simple powershell script that will go into Event viewer on remote host and grab the log from it. The problem on hand is that the client is unable to connect to remote server with new-pssesion command.

When i try to open connection from client to server, i get this error:

PS C:\Users\user> New-PSSession -ComputerName SERVERHOSTNAME -Credential DOMAIN\user
New-PSSession : [SERVERHOSTNAME] Connecting to remote server SERVERHOSTNAME failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer 
name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM 
firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ New-PSSession -ComputerName SERVERHOSTNAME -Credential DOMAIN\user
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionOpenFailed

have verified that the psremoting is enabled and winrm service is running on both client and server. Still no luck. I have temporary disabled windows firewall just to rule it out of equation. Both systems are using Windows Server 2012 R2.

Any ideas guys?

June 7, 2016 at 8:54 pm

Just to be sure the traffic isn't being blocked, try: Test-NetConnection -ComputerName SERVERHOSTNAME -Port 5985

June 7, 2016 at 8:55 pm

If that TCP test fails, then you haven't got connectivity for some reason. (Could be firewalls, could be listener configured wrong on a different port, etc.)

June 7, 2016 at 10:00 pm

Hi Dave,
I did the test and here is the output running the test on client side:

ComputerName           : SERVER HOSTNAME
RemoteAddress          : SERVER HOST IP
RemotePort             : 5985
InterfaceAlias         : Ethernet
SourceAddress          : CLIENT IP ADDRESS
PingSucceeded          : True
PingReplyDetails (RTT) : 7 ms
TcpTestSucceeded       : True

Here is also same test run but from the server initiated to client:

ComputerName           : CLIENT HOSTNAME
RemoteAddress          : CLIENT IP ADDRESS
RemotePort             : 5985
InterfaceAlias         : Ethernet
SourceAddress          : SERVER IP ADDRESS
PingSucceeded          : True
PingReplyDetails (RTT) : 12 ms
TcpTestSucceeded       : True