我需要从 Windows 7 工作站中提取本地登录/注销列表。我已经保存了 evtx 格式的安全事件日志副本,但我遇到了一些问题。
以下 powershell 提取 ID4624或的所有事件4634:
Get-WinEvent -Path 'C:\path\to\securitylog.evtx' | where {$_.Id -eq 4624 -or $_.Id -eq 4634}
然后我只想过滤logon type = 2 (local logon). 管道到:
| where {$_.properties[8].value -eq 2}
但是似乎删除了所有id=4634(注销)事件。
即使对于事件id = 4624事件,也不存在用户 ID。例如管道:
| select-object -property Timecreated,TaskDisplayName,MachineName,userid
或以其他方式连接到Export-Csv,userid则为空白。
两个问题是:
- 为什么 id 为 4634 的事件在通过管道传输到 where 时会丢失
{$_.properties[8].value -eq 2}? - 为什么是
userid空的?我怎样才能得到userid?