event log failed logins
-
2012년 3월 9일 금요일 오전 9:29
Hi,
I wrote my first powershel script today to extract failed logins for a particular database on one of our servers.
$startdate = (Get-Date).AddDays(-31) $enddate = (Get-Date -f yyyy-MM-dd) $out_file = "\\sharepoint\DavWWWRoot\IT\\Access Login Failures\Failed_Logins_" + $enddate + ".csv" Get-EventLog Application -Computer DB01 -After $startdate |where{$_.Message -like "*Password*" -and $_.Message -notlike "*A'. *" }|where{$_.EventId -eq "18456"}|select username,message,timegenerated | export-csv $out_file -forceIt works well and extracts the two fields I need. Although I want to improve it by making it select only the username from the Eventlog 'message' column. The username is surrounded by two apostrophies e.g. 'USERNAME'.
Is this possible?
- 편집됨 nick9one1 2012년 3월 9일 금요일 오전 9:37
모든 응답
-
2012년 3월 9일 금요일 오전 10:13
Hi,
Not tested but should works: @{l="username";e={$_.message -match "'.+'" | out-null; $matches[0]}}
Get-EventLog Application -Computer DB01 -After $startdate | where{$_.Message -like "*Password*" -and $_.Message -notlike "*A'. *" -and $_.EventId -eq "18456"} | select @{l="username";e={$_.message -match "'.+'" | out-null; $matches[0]}},message,timegenerated | export-csv $out_file -force- 답변으로 제안됨 Yan Li_Microsoft Contingent Staff, Moderator 2012년 3월 12일 월요일 오전 6:56
- 답변으로 표시됨 Yan Li_Microsoft Contingent Staff, Moderator 2012년 3월 15일 목요일 오전 1:27

