Advertisement
Guest User

Untitled

a guest
Sep 7th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. $time = [int64](New-TimeSpan (get-date "01/01/2017") (get-date "08/10/2018")).TotalMilliseconds
  2. $filter = "*[System[TimeCreated[timediff(@SystemTime) < $time] and EventID=4624] and EventData[Data[@Name='LogonType']=10]]"
  3. $results = @(
  4. Get-WinEvent -FilterXPath $filter -LogName Security | Foreach {
  5. $evt = $_
  6. $addr = $evt.Properties[18].Value
  7. $textcolor = $host.ui.rawui.foregroundcolor
  8. $host.ui.rawui.foregroundcolor = "red"
  9.  
  10. if ($addr -like "192.168.0*") {$host.ui.rawui.foregroundcolor = "DarkGreen"}
  11. if ($addr -like "10.*") {$host.ui.rawui.foregroundcolor = "yellow"}
  12. "" | Select-Object @{n="Time";e={$evt.TimeCreated}},@{n="UserName";e={$evt.Properties[5].Value}},@{n="Address";e={$addr}}
  13. $host.ui.rawui.foregroundcolor = $textcolor
  14. }
  15. )
  16. $results | export-csv -Encoding UTF8 -Path d:\so1.csv -NoTypeInformation -Delimiter ";"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement