问题
I would love to get help on how can I see all users who have logged in to my computer (and when recently?) Via cmd command and by registry.
回答1:
If you are on a supported Windows system, PowerShell is available. Using it to see logged in users on another computer will require that PowerShell Remoting be competently configred.
=== Get-LoggedOnUsers.ps1
[CmdletBinding()]
param (
[Parameter(Mandatory=$false,ValueFromPipeline=$True)]
[string[]]$ComputerName = [System.Net.Dns]::GetHostName()
)
foreach ($Computer in $ComputerName) {
((Get-CimInstance -ClassName Win32_LoggedOnUser -ComputerName $Computer).Antecedent |
Sort-Object -Unique) |
ForEach-Object { "$($_.domain)\$($_.name)" }
}
Run it with:
powershell -NoLogo -NoProfile -File ".\Get-LoggedOnUsers.ps1"
来源:https://stackoverflow.com/questions/63012412/how-can-i-see-all-users-who-have-logged-in-to-my-computer-and-when-recently-v