Last active
December 12, 2020 01:04
-
-
Save mySYSMON/2339cf034c057f6211cb44581148c4ea to your computer and use it in GitHub Desktop.
sysmon1-stats-count-by-image.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$events = Get-WinEvent -FilterHashtable ` | |
@{ ` | |
logname='Microsoft-Windows-Sysmon/Operational'; ` | |
id=1; ` | |
StartTime=(Get-Date).AddHours(-1); ` | |
EndTime=get-date ` | |
} | |
$dict = @{} | |
foreach ($log in $events) | |
{ | |
[xml]$xmllog = $log.toXml() | |
$tmp = $xmllog.event.eventdata.data | where Name -eq 'image' | select '#text' | |
$image = $tmp.'#text' | |
$value = $dict[$image] | |
if ($value -eq $null) | |
{ | |
$value = 1 | |
$dict.add($image,$value) | |
} | |
else | |
{ | |
$value = $value + 1 | |
$dict[$tmp] = $value | |
} | |
} | |
$dict.GetEnumerator() | sort -Property value -Descending | |
# RUN LIKE THIS | |
# sysmon1-stats-count-by-image.ps1 | format-list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment