首页/系统/Windows 运维速查/域账号长期未登录审计(LastLogonDate 陷阱)
本包目录(413 条)
CMD 常用命令74 条PowerShell 基础66 条网络排查41 条服务与进程42 条磁盘与文件43 条用户与权限34 条
AD 域与组策略39 条
日志与事件38 条远程管理36 条

域账号长期未登录审计(LastLogonDate 陷阱)

清理僵尸账号前搞清时间字段:LastLogon 不复制、LastLogonTimestamp 复制但滞后(默认约 14 天),LastLogonDate 是换算视图。

Windows 运维速查系统更新于 2026-10-12
LastLogon精确但不复制,属单台 DC 局部
LastLogonTimestamp复制到全域,滞后约 9-14 天
LastLogonDatePowerShell 视图字段,来源是 LastLogonTimestamp

常用示例

常用示例
$cut = (Get-Date).AddDays(-90)
Get-ADUser -Filter 'LastLogonDate -lt $cut -and Enabled -eq $true' -Properties LastLogonDate, PasswordLastSet | Select-Object Name, SamAccountName, LastLogonDate, PasswordLastSet | Sort-Object LastLogonDate | Export-Csv stale_users.csv -NoTypeInformation -Encoding UTF8
审计清单必须业务确认后再处理:外派、产假、共享账号都可能“看起来”长期未登录。

易错点

  • 用 LastLogon 单台 DC 查值为空会误判“从未登录”
  • LastLogonTimestamp 滞后让 30 天检查存在抖动窗口

数据来源与参考

  • Microsoft Learn:LastLogonTimestamp
  • Microsoft Learn:Search-ADAccount -AccountInactive

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌