Created
November 5, 2022 16:30
-
-
Save RoadToDream/808379d2addb4cc0fd36a49b112ca2d7 to your computer and use it in GitHub Desktop.
Toggle Defender Real-time Protection.
This file contains hidden or 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
##################################################################### | |
# Toggle Defender Real-time Protection | |
# | |
# Syntax: | |
# | |
# Defender - toggle Real-time Protection (default) | |
# Defender -state 0/1 - Set Real-time Protection to Enable/Disable | |
##################################################################### | |
param( | |
[int] $state = -1 | |
) | |
if ($state.equals(-1)) { | |
$TargetState = $(Get-MpComputerStatus).RealTimeProtectionEnabled | |
Set-MpPreference -DisableRealtimeMonitoring $TargetState | |
} | |
else { | |
$TargetState=[boolean]($state -xor 1) | |
Set-MpPreference -DisableRealtimeMonitoring $TargetState | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment