Skip to content

Instantly share code, notes, and snippets.

@tuantmb
Forked from svch0stz/defenderwatch.ps1
Created June 18, 2021 09:27
Show Gist options
  • Save tuantmb/093314c9cd24cb842f9e6969d74373a6 to your computer and use it in GitHub Desktop.
Save tuantmb/093314c9cd24cb842f9e6969d74373a6 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