查看 Windows 最近的登录记录(4624 事件)

用 PowerShell 列出 Windows 安全日志里最近的成功登录事件,看看谁在什么时间登录过电脑。

Windows安全PowerShell事件日志低风险
运行 Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4624} -MaxEvents 10,查看 TimeCreated 和 Account 两列。

01命令

命令
$ Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4624} -MaxEvents 10 | Select-Object TimeCreated, @{n='Account';e={$_.Properties[5].Value}}, @{n='Type';e={$_.Properties[8].Value}}

02作用说明

每次成功登录——本机键盘、远程桌面、网络访问、服务登录——都会在安全日志中写入一条 4624 事件,这条命令会取出最新的 10 条。Logon Type 字段说明登录方式:2 是本机键盘登录,10 是远程桌面,3 是网络共享访问。如果发现陌生账号在奇怪的时间反复登录,就值得进一步排查。

03风险

风险低风险
使用条件Run in an elevated (Administrator) PowerShell — the Security log is readable only by admins
!注意: 安全日志里也有大量系统/服务登录记录,按 Account 列筛选才能只看真人登录。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • 4624(S): An account was successfully logged on
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Defines Windows security event 4624 for successful logons and documents its fields, including Account Name (index 5) and Logon Type (index 8).

最后验证: 2026-09-18 · 分类: 安全与隐私

06相关方案