One-Liner: PS Remoting – Connected Clients

They say "imitation is the sincerest form of flattery". Who 'they' are remains a mystery. I do know that 'they' seem to say a lot of things, some of which they probably shouldn't...

Still, let me start this post with imitation; let me introduce the PoSh chickens. Actually, the PoSh chickens have nothing to do with the one-liner I want to discuss, because they don't use PowerShell... despite my best efforts to teach them.

Where was I? Oh, yes, the one-liner. This one shows users and clients connected to a host via PS Remoting:


Get-WSManInstance -ConnectionURI "http://$($env:COMPUTERNAME):5985/wsman" -ResourceURI Shell -Enumerate |

Select-Object Owner,@{n='HostName';e={(Resolve-DNSName $_.ClientIP).NameHost}},ClientIP


Here's some sample output:


What's going on here then?

We use the Get-WSManInstance cmdlet to get information on a specific resource on a particular endpoint. Here's a discussion of the parameters and their values from the example:

  • ConnectionURI - points to the local computer's WinRM listener on the standard port of 5985
  • ResourceURI - asks for Shell resources
  • Enumerate - returns all instances of a resource


Select-Object is then used to pull back two of the properties - Owner and ClientIP. It also creates a custom property - HostName - by using the Resolve-DNS cmdlet to process the look up ClientIP property as part of an expression in a hash table.

Right, back to the PoSh garden and the PoSh chickens!


Comments (1)

Skip to main content