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

后端 未结 6 1392
无人及你
无人及你 2020-11-29 22:44

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

6条回答
  •  情话喂你
    2020-11-29 23:04

    Here is my Approach based on DarKalimHero's Suggestion by selecting only on Explorer.exe processes

    Function Get-RdpSessions 
    {
        param(
            [string]$computername 
        )
    
        $processinfo = Get-WmiObject -Query "select * from win32_process where name='explorer.exe'" -ComputerName $computername
    
        $processinfo | ForEach-Object { $_.GetOwner().User } | Sort-Object -Unique | ForEach-Object { New-Object psobject -Property @{Computer=$computername;LoggedOn=$_} } | Select-Object Computer,LoggedOn
    }
    

提交回复
热议问题