Skip to content

Instantly share code, notes, and snippets.

@Davidblkx
Created July 21, 2021 08:03
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 Davidblkx/86bfaa1f863f13d7e606c89c6990d2b7 to your computer and use it in GitHub Desktop.
Save Davidblkx/86bfaa1f863f13d7e606c89c6990d2b7 to your computer and use it in GitHub Desktop.
Enable disable windows defender real time protection
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" +$myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$status = (-Not (Get-MpPreference).DisableRealtimeMonitoring)
Set-MpPreference -DisableRealtimeMonitoring $status
$status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment