Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 896
RayofCommand Avatar asked Apr 22 '14 12:04

RayofCommand


People also ask

How do I see active sessions in PowerShell?

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

How can I tell who is logged into a computer using Active Directory?

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.

How can I tell if a user is logged in PowerShell?

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.

Which function searches the current logon domain by default in PowerShell?

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.


1 Answers

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 
like image 115
Hyon Avatar answered Sep 25 '22 03:09

Hyon