Few PowerShell One-Liners To Check WinRM Settings on Remote Machines

Written by Tao Yang

To Check if WinRM has been enabled on a Remote machine:

$RemoteMachine = “Remote Machine Name”

[system.convert]::ToBoolean(((winrm get winrm/config/winrs -r:$remotemachine | ?{$_ -imatch "AllowRemoteShellAccess"}).split("="))[1].trim())

To Check the Default HTTP listener port on a remote machine:

$RemoteMachine = “Remote Machine Name”

[System.Convert]:: ToInt32(((winrm get winrm/config/Service/DefaultPorts -r:$RemoteMachine | ?{$_ -imatch "HTTP = " }).split("="))[1].trim())

To Check the Default HTTPS listener port on a remote machine:

$RemoteMachine = “Remote Machine Name”

[System.Convert]:: ToInt32(((winrm get winrm/config/Service/DefaultPorts -r:$RemoteMachine | ?{$_ -imatch "HTTPS = " }).split("="))[1].trim())

image

3 comments on “Few PowerShell One-Liners To Check WinRM Settings on Remote Machines

  1. Good one – will come handy for tshoot.

  2. Pingback: checking WINRM from powershell | becknspace

  3. Not sure it is appropriate to ask but I will ask anyway, since you are so good at Powershell.. Is it possible to create a Powershell script to list all existing permissions on share folders or even subfolders, then use a variable to find groups or users who don’t exist in the permission sets, and then add new groups or users in permission set …It maybe a very complicated script……

Leave a Reply