2012-11-01 26 views
0

我有以下PowerShell来输出失败的登录事件IP地址的列表:PowerShell的 - 房源从安全日志失败的IP地址,包括数

$DT = [DateTime]::Now.AddDays(-1) # check only last 24 hours 

$l = Get-EventLog -LogName 'Security' -InstanceId 4625 -After $DT | Select-Object @{n='IpAddress';e={$_.ReplacementStrings[-2]} } 
$g = $l | group-object -property IpAddress | where {$_.Count -gt 20} | Select -property Name | export-csv c:\users\export.csv 

我真的想改善它,所以它的输出像现在这样的IP地址,再加上$ _。Count。我已经尝试了一些东西,但我认为我陷入了SQL世界!

回答

2

我认为,所有你需要做的是,在第二管道,更换

Select -property Name 

Select -property Name, Count 

(不过,我想通过看对对象的属性检查从返回group-objectget-member第一个。)