How to test WinRM connectivity using PowerShell?


In system admin role or as a PowerShell engineer you need to connect to many computers remotely. So as the first step, we need to test the remote connectivity by applying ping command or Test-Connection but many organizations have a stringent policy, and some of the servers ICMP packets are blocked. In such a case you can check connectivity with WINRM.

If the WINRM is not allowed, you can ask your windows administrator to enable a firewall exception for WINRM. WINRM is the thing that PowerShell uses it for remoting purposes. So before connecting to remote server it is necessary to test remote WINRM connectivity with PowerShell. We need to use Test- WS command for it.

Test-WSMan -ComputerName Test1-Win2k12

If you get the below response, then the WinRM connection is successful.

PS C:\Users\Administrator> Test-WSMan -ComputerName Test1-Win2k12
wsmid               :    http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd  
ProtocolVersion     :    http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor       :    Microsoft Corporation
ProductVersion      :    OS: 0.0.0 SP: 0.0 Stack: 3.0

If PSremoting is not enabled or WinRM is blocked by the firewall, you will get an error message.

Updated on: 25-Jul-2020

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements