Created
April 13, 2017 09:23
-
-
Save melvinsh/70c74e035e12a9a2dac9e8b5617fbff1 to your computer and use it in GitHub Desktop.
Toggle Windows Defender's Real-time Protection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run as administrator | |
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit | |
} | |
$Preferences = Get-MpPreference | |
if($Preferences.DisableRealtimeMonitoring) { | |
Set-MpPreference -DisableRealtimeMonitoring 0 | |
} else { | |
Set-MpPreference -DisableRealtimeMonitoring 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment