In search of this same solution, I found what I needed under a different question in stackoverflow:
Powershell-log-off-remote-session. The below one line will return a list of logged on users.
query user /server:$SERVER
More Related Contents:
- Get-Aduser -Filter will not accept a variable
- Delete files older than 15 days using PowerShell
- Powershell – Reboot and Continue Script
- PowerShell is missing the terminator: “
- Using PowerShell to remove lines from a text file if it contains a string
- Powershell: Set a Scheduled Task to run when user isn’t logged in
- List of all colors available for PowerShell?
- What’s the best way to determine the location of the current PowerShell script?
- Is there a way to make a PowerShell script work by double clicking a .ps1 file?
- Redirecting standard input\output in Windows PowerShell
- How to perform keystroke inside powershell?
- Get remote registry value
- Executing an EXE file using a PowerShell script
- Obtaining ExitCode using Start-Process and WaitForExit instead of -Wait
- Redirection of standard and error output appending to the same log file
- How to properly -filter multiple strings in a PowerShell copy script
- try, catch doesent seem to work
- How to export data to CSV in PowerShell?
- Methods to hex edit binary files via Powershell
- Powershell ConvertTo-json with embedded hashtable
- How remove accents in PowerShell?
- Replacing a string with a variable in Get-ADGroup
- Using Invoke-Command -ScriptBlock on a function with arguments
- Get-ADGroupMember : The size limit for this request was exceeded
- Powershell Using Start-Process in PSSession to Open Notepad
- Hashtables and key order
- Check if a file exists or not in Windows PowerShell?
- Difference between PowerShell Console and PowerShell ISE
- List hidden sub-directories and sizes
- How to effectively use the `-Filter` parameter on Active Directory cmdlets?