Skip to content

Instantly share code, notes, and snippets.

@iexpurgator
Created December 7, 2022 17:57
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 iexpurgator/e593f3dab2e2a710ddb0e268decc781d to your computer and use it in GitHub Desktop.
Save iexpurgator/e593f3dab2e2a710ddb0e268decc781d to your computer and use it in GitHub Desktop.
Simple windows defender toggle
## Shortcut (Administrator): powershell.exe -ExecutionPolicy Bypass -File "<full path>\windef_toggle.ps1"
$preferences = Get-MpPreference
$realtimeDisableStatus = $preferences.DisableRealtimeMonitoring
# Set-MpPreference -DisableRealtimeMonitoring (!$preferences.DisableRealtimeMonitoring)
if ($realtimeDisableStatus) { # Disabled -> Enable
Set-MpPreference -DisableRealtimeMonitoring $false
Set-MpPreference -MAPSReporting Advanced
Set-MpPreference -SubmitSamplesConsent 1
Set-MpPreference -DisableBehaviorMonitoring $false
} else { # Enable -> Disabled
Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -MAPSReporting Disabled
Set-MpPreference -SubmitSamplesConsent 2
Set-MpPreference -DisableBehaviorMonitoring $true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment