Overview

This function parses the results of query user to provide object based results:  ComputerName, UserName, SessionName, Id, State, IdleTime and LogonTime

Dependencies


Instructions

PowerShell
Edit|Remove
#Add Get-UserSession to your session: 
    . "\\Path\To\Get-UserSession.ps1" 
 
#Get help for Get-UserSession 
    Get-Help Get-UserSession -Full 
 
#Get sessions on a remote server 
    Get-UserSession -ComputerName Server14 
 
#Get sessions on a group of remote servers, parse the idle time 
    Get-UserSession -ComputerName $Servers -ParseIdleTime

Notes

Thanks to Boe Prox for his function that parses query session.

Please note that there is a fantastic module written by Shay Levy that may fit your needs: PSTerminalServices.  I wrote this function to use when I don't want to depend on external modules for a script.  In all other cases, I use Shay's solution.  

Changes