Skip to content

Instantly share code, notes, and snippets.

@philippwiddra
Created March 21, 2017 11:49
Show Gist options
  • Save philippwiddra/7ae903296f67810b06ff1c6139bf2a1f to your computer and use it in GitHub Desktop.
Save philippwiddra/7ae903296f67810b06ff1c6139bf2a1f to your computer and use it in GitHub Desktop.
$filterXml = '<QueryList>
<Query Id="0" Path="System">
<Select Path="System">*[System[(Level=1 )]]</Select>
</Query>
</QueryList>'
$pcs = (Get-ADComputer -Filter * | ? { Test-Connection $_.DNSHostName -Quiet -Count 1 }).DNSHostName
$pcs | % {
Get-WinEvent -FilterXml $filterXml -ComputerName $_ | ? TimeCreated -GT (Get-Date).AddMonths(-1)
} | Select MachineName, TimeCreated, ProviderName, Id, Message | Out-GridView -Title "Critical System Errors Last Month"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment