查看各用户账号的最后登录时间
用 PowerShell 列出本机每个用户最近一次登录的时间和登录次数,了解共用电脑的使用情况。
在管理员 PowerShell 中运行 `Get-CimInstance Win32_NetworkLoginProfile | Select-Object Name, LastLogon, NumberOfLogons`。
01命令
命令
$ Get-CimInstance Win32_NetworkLoginProfile | Select-Object Name, LastLogon, NumberOfLogons02作用说明
家庭或办公室共用电脑时,往往想知道某个账号最近有没有被用过。Windows 会在 Win32_NetworkLoginProfile 这个 WMI 类里按账号记录登录活动,包括最后一次登录时间和累计登录次数。一条查询命令就能把这些信息整理成表格,不必打开事件查看器翻日志。
03风险
!注意: 个别条目的 LastLogon 可能显示为原始数字(未转换的 Windows 时间戳);从未交互登录过的账号可能显示为空。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- Win32_NetworkLoginProfile class | Microsoft Learn依据: Win32_NetworkLoginProfile exposes LastLogon and NumberOfLogons for user accounts on the machine.
- Get-CimInstance cmdlet | Microsoft Learn依据: Get-CimInstance retrieves WMI class instances such as Win32_NetworkLoginProfile.
最后验证: 2026-09-19 · 分类: 系统与设置