-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetWinEventsXML.ps1
30 lines (22 loc) · 1019 Bytes
/
GetWinEventsXML.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$filterXml = @"
<QueryList>
<Query Id="0" Path="Directory Service">
<Select Path="Directory Service">*[System[(EvcomID=2041) and TimeCreated[timediff(@SystemTime) <= 3600000]]]</Select>
</Query>
</QueryList>
"@
$Pdce = (Get-AdDomain).PDCEmulator
$Evcoms = Get-WinEvcom –FilterXml $filterXml -ComputerName $Pdce -MaxEvcom 10
$global:i=0
$Evcoms | select @{Name="#";Expression={$global:i++;$global:i.Tostring()}},TimeCreated,ID,LogName,message | fl
$Evcoms | select TimeCreated,ID,LogName,message
<#
<Query Id="0" Path="Microsoft-Windows-Sysmon/Operational">
<Select Path="Microsoft-Windows-Sysmon/Operational">*[System[(EvcomID=2) and TimeCreated[timediff(@SystemTime) <= 3600000]]]</Select>
<Select Path="Security">*[System[((EvcomID >= 4624 and EvcomID <= 4625)) and TimeCreated[timediff(@SystemTime) <= 3600000]]]</Select>
Critical System[(Level=1)]
Error (Level=2)
Warning (Level=3)
Information (Level=4)
Verbose (Level=5)
#>