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.
Powershell script to see currently logged in users (domain and machine) + status (active, idle, away)
Use the Find feature in Active Directory Users and Computers to search for a user account and see which computer they last logged on to. You can also do a search using the description field for COMPUTERNAME to find the user that last logged onto a specific computer.
Use the query Command to Get Logged on Users in PowerShell Windows has a built-in command-line tool called the query command to list all the currently logged-on users on a computer. The command also shows us if the user logged on via a remote desktop session or locally to the computer.
If you specify none of those scope parameters, this parameter finds all global catalogs that are in the current domain. Connects a computer to a remote server or domain that you specify. By default, dsquery connects the computer to the domain controller in the logon domain.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With