Powershell script to see currently logged in users (domain and machine) + status (active, idle, away)

active-directorypowershellpowershell-2.0powershell-3.0windows-server-2012

I am searching for a simple command to see logged on users on server.
I know this one :

Get-WmiObject -Class win32_computersystem

but this will not provide me the info I need.
It returns :
domain
Manufactureer
Model
Name (Machine name)
PrimaryOwnerName
TotalPhysicalMemory

I run Powershell 3.0 on a Windows 2012 server.

Also

Get-WmiObject Win32_LoggedOnUser -ComputerName $Computer | Select Antecedent -Unique

gives me not the exact answers I need.
I would love to see as well the idle time, or if they are active or away.

Best Answer

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
Related Topic