如何在以下输出中获取“登录失败的帐户”部分的“帐户名称” Get-EventLog
?我知道它涉及替换字符串,但这只是没有得到它:
Get-EventLog -ComputerName fs2 -Logname security |
? {$_.eventid -eq "4625"} |
select machinename, eventid, @{n='AccountName';e={$_.ReplacementStrings[2]}},
entrytype, message |
Export-Csv 1.csv -NoTypeInformation
示例事件日志条目:
时间创建:2016 年 5 月 18 日上午 8 点 55 分 43 秒 ProviderName : Microsoft-Windows-安全-审计 编号:4625 消息:帐户无法登录。 主题: 安全 ID:S-1-5-21-1287344763-2688370722-3395302928-19873 帐户名称:service_adfs 账户域:DOMAIN 登录 ID:0xD62E4 登录类型:3 登录失败的帐户: 安全 ID:S-1-0-0 帐户名称:user.thatiwant@DOMAIN.com 帐户域:
编辑:不知道为什么他们编辑我的帖子以包含旧 cmdlet,与较新的 cmdlet get-winevent 一起工作得很好。正则表达式对我不起作用。不过,这似乎可行。
get-winevent -computername fs1 -FilterHashtable @{Logname='Security';Id='4625'} |select timecreated, message, machinename, eventid, @{n='AccountName';e={$_.ReplacementStrings[5]}}