Skip to content

Instantly share code, notes, and snippets.

@PrivateLocker
Created January 5, 2020 01:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PrivateLocker/6711c4fe88eae75774284bd6efc377dc to your computer and use it in GitHub Desktop.
Save PrivateLocker/6711c4fe88eae75774284bd6efc377dc to your computer and use it in GitHub Desktop.
DisableD3f3nd3r
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
}
function Check-IsElevated
{
$id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$p = New-Object System.Security.Principal.WindowsPrincipal($id)
if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
{
Write-Output $true
}
else
{
Write-Output $false
}
}
function Check-IsWindows10
{
if ([System.Environment]::OSVersion.Version.Major -ge "10")
{
Write-Output $true
}
else
{
Write-Output $false
}
}
If ($ProcessError)
{
Write-Warning -Message "Something went wrong!";
pause;
}
if (!(Check-IsElevated))
{
$ProcessError
}
if (!(Check-IsWindows10))
{
exit 0
}
function disabledefender {
try {
Set-MpPreference -Force -DisableRealtimeMonitoring 1
} catch {
$ProcessError
}
try {
Set-MpPreference -Force -DisablePrivacyMode 1
} catch {
$ProcessError
}
try {
Set-MpPreference -Force -DisableAutoExclusions 0
} catch {
$ProcessError
}
try {
Set-MpPreference -Force -DisableScanningNetworkFiles 1
} catch {
$ProcessError
}
try {
Set-MpPreference -Force -DisableIntrusionPreventionSystem 1
} catch {
$ProcessError
}
try {
Set-MpPreference -Force -MAPSReporting Disabled
} catch {
$ProcessError
}
try {
Set-MpPreference -Force -SubmitSamplesConsent Never
} catch {
$ProcessError
}
Set-MpPreference -Force -CheckForSignaturesBeforeRunningScan 0
Set-MpPreference -Force -DisableBehaviorMonitoring 1
Set-MpPreference -Force -DisableIOAVProtection 1
Set-MpPreference -Force -DisableScriptScanning 1
Set-MpPreference -Force -DisableRemovableDriveScanning 1
Set-MpPreference -Force -DisableBlockAtFirstSeen 1
Set-MpPreference -Force -PUAProtection Disabled
Set-MpPreference -Force -RandomizeScheduleTaskTimes 0
Set-MpPreference -Force -SignatureUpdateInterval 32000
Set-MpPreference -Force -SignatureUpdateInterval 32000
Set-MpPreference -Force -ReportingAdditionalActionTimeOut 1
Set-MpPreference -Force -ReportingCriticalFailureTimeOut 1
Set-MpPreference -Force -ReportingNonCriticalTimeOut 1
Set-MpPreference -Force -DisableArchiveScanning 1
Set-MpPreference -Force -DisableEmailScanning 1
Set-MpPreference -Force -EnableControlledFolderAccess Disabled
Set-MpPreference -Force -EnableNetworkProtection Disabled
Set-MpPreference -Force -DisableRestorePoint 1
Set-MpPreference -Force -DisableScanningMappedNetworkDrivesForFullScan 1
Set-MpPreference -Force -DisableIntrusionPreventionSystem 1
Set-MpPreference -Force -UILockdown 1
Write-Host "If no errors, Script is finished. Defender is now Disabled."
}
disabledefender
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment