Skip to content

Instantly share code, notes, and snippets.

@dstreefkerk
Created June 22, 2017 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstreefkerk/5de1e9cd991d6b5b62ee96f64c4fd60b to your computer and use it in GitHub Desktop.
Save dstreefkerk/5de1e9cd991d6b5b62ee96f64c4fd60b to your computer and use it in GitHub Desktop.
Pull AppLocker logs out of the Forwarded Logs folder on a Windows Event Collector, and present them in a GridView
Function Get-AppLockerLogs {
$filter = '
<QueryList>
<Query Id="0" Path="ForwardedEvents">
<Select Path="ForwardedEvents">*[System[Provider[@Name="Microsoft-Windows-AppLocker"] and (Level=2 or Level=3)]]</Select>
</Query>
</QueryList>
'
$data = Get-WinEvent -FilterXml $filter -Oldest
foreach ($log in $data) {
[xml]$tempXML = $log.ToXml()
$objSID = $null
$objUser = $null
$objSID = New-Object System.Security.Principal.SecurityIdentifier($log.UserId.Value)
try {
$objUser = $objSID.Translate([System.Security.Principal.NTAccount])
}
catch {
$objUser = $log.UserId.Value
}
$tempObject = [ordered]@{
LogName = $log.LogName
TimeCreated = $log.TimeCreated
FilePath = $tempXML.Event.UserData.RuleAndFileData.FilePath
ComputerName = $log.MachineName
UserID = $objUser.Value
Signer = $tempXML.Event.UserData.RuleAndFileData.Fqbn
Message = $tempXML.Event.RenderingInfo.Message
}
New-Object PSObject -Property $tempObject
}
}
Get-AppLockerLogs | Out-GridView -Wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment