Skip to content

Instantly share code, notes, and snippets.

@sassdawe
Forked from svch0stz/defenderwatch.ps1
Created June 7, 2021 05:32
Show Gist options
  • Save sassdawe/af59fcc5c262d911d18b4e41fb9c850a to your computer and use it in GitHub Desktop.
Save sassdawe/af59fcc5c262d911d18b4e41fb9c850a to your computer and use it in GitHub Desktop.
WMI Watcher for Windows Defender RealtimeMonitoring
$WMI = @{
Query = "SELECT * FROM __InstanceModificationEvent WITHIN 5 WHERE TargetInstance ISA 'MSFT_MpPreference' AND TargetInstance.DisableRealtimeMonitoring=True"
Action = {
#$Global:Data = $Event
Write-Host "Defender Configuration change - DisableRealtimeMonitoring:"$Event.SourceEventArgs.NewEvent.TargetInstance.DisableRealtimeMonitoring"(Old Value:"$Event.SourceEventArgs.NewEvent.PreviousInstance.DisableRealtimeMonitoring")"
}
Namespace = 'root\microsoft\windows\defender'
SourceIdentifier = "Defender.DisableRealtimeMonitoring"
}
$Null = Register-WMIEvent @WMI
#Uninstall: Unregister-Event Defender.DisableRealtimeMonitoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment