How can i see all users who have logged in to my computer (and when recently?) Via cmd command and by registry

折月煮酒 提交于 2020-08-10 19:34:15

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!