SHOW:
|
|
- or go back to the newest paste.
| 1 | $Logs=Get-eventlog -logname "Security" -Instanceid 4663|Sort-Object -Property TimeCreated | |
| 2 | $temp="" | Select AccountName,AccountDomain,PathName,Action,TimeWritten | |
| 3 | $check = 0 | |
| 4 | $Result = Foreach($l in $Logs) | |
| 5 | {
| |
| 6 | $re = "" | Select AccountName,AccountDomain,PathName,Action,TimeWritten | |
| 7 | $split = $l.Message -split "`n" | |
| 8 | [string]$Act = $split[19].Replace("`t","")
| |
| 9 | ||
| 10 | ||
| 11 | # Truong hop Rename | |
| 12 | if ($check -eq 1 -And $Act -like "*%%4417*") | |
| 13 | {
| |
| 14 | $temp.Action = "RENAME" | |
| 15 | $temp | |
| 16 | $check = 0 | |
| 17 | } | |
| 18 | elseif($check -eq 1 -And $Act -notlike "*%%4417*") | |
| 19 | {
| |
| 20 | $temp | |
| 21 | $check = 0 | |
| 22 | } | |
| 23 | ||
| 24 | #Truong hop DELETE | |
| 25 | if ($Act -like "*%%1537*") | |
| 26 | {
| |
| 27 | $re.AccountName = $split[4] | |
| 28 | $re.AccountDomain = $split[5] | |
| 29 | $re.PathName = $split[11] | |
| 30 | $re.Action = "DELETE" | |
| 31 | $re.TimeWritten = $l.TimeWritten | |
| 32 | $check = 1 | |
| 33 | $temp = $re | |
| 34 | } | |
| 35 | ||
| 36 | #Truong hop Create or Modify | |
| 37 | if ($Act -like "*%%4417*") | |
| 38 | {
| |
| 39 | $re.AccountName = $split[4] | |
| 40 | $re.AccountDomain = $split[5] | |
| 41 | $re.PathName = $split[11] | |
| 42 | $re.Action = "CREATE/MODIFY" | |
| 43 | $re.TimeWritten = $l.TimeWritten | |
| 44 | $re | |
| 45 | } | |
| 46 | } | |
| 47 | if($Result -eq $null) | |
| 48 | {
| |
| 49 | Write-host "No matches found" | |
| 50 | exit | |
| 51 | } | |
| 52 | ||
| 53 | $Result|Export-csv E:\test1.csv | |
| 54 | Write-host "Done!" |