Microsoft Defender Antivirus ships enabled on Windows Server 2019 and 2022, and there are legitimate reasons to turn it off - most commonly to deploy a third-party enterprise antivirus that Microsoft does not recommend running alongside Defender's real-time protection. This guide covers four approaches: a full uninstall with Uninstall-WindowsFeature -Name Windows-Defender-Features (the recommended method on servers with no dependency on Defender for Endpoint), a Group Policy method for domain fleets, a registry method for granular control or passive mode, and the equivalent Server Manager GUI wizard.
Because this is a high-risk, non-read-only change, it is treated as a full procedure: create a system restore point and export the registry first, keep your replacement AV installer staged, and run the verification steps at the end. Never leave a production server without antivirus - plan to install the replacement immediately after disabling Defender to minimize the security gap. Note that on newer builds some registry keys such as DisableAntiSpyware may be ignored, which is why the uninstall or Group Policy methods are usually the more reliable choice.
Before you start
What you will learn
- You will learn how to disable or completely remove Microsoft Defender Antivirus on Windows Server 2019 and 2022 using PowerShell, Group Policy, the registry, or the Server Manager GUI. You will also learn how to verify the change and confirm that replacement protection is active.
- Disabling Defender without preparation leaves a server exposed to attack within minutes and can create conflicts with third-party antivirus products. Doing it in the correct order - with a backup, a replacement AV ready, and post-change verification - keeps the server protected and recoverable.
Requirements
- You need local Administrator rights on the target Windows Server 2019/2022 host (or Domain Admin / delegated GPO edit rights for the Group Policy method). Perform the work at the console or over an RDP session that will survive a reboot.
- Local Administrator on the target server
- Domain Administrator or delegated Group Policy edit rights (Method 2 in domain environments)
Good to know
Quick answer
On a server that does not depend on Defender for Endpoint, the cleanest way to remove Microsoft Defender is to uninstall the feature from an elevated PowerShell prompt, then reboot and verify. Domain fleets can instead disable it via Group Policy, and advanced cases can use registry settings or passive mode. Always back up first and have a replacement antivirus ready to install.
Uninstall-WindowsFeature -Name Windows-Defender-Features -RestartStep-by-step tutorial
8 stepsBack up and prepare a replacement antivirus
Protect the server against rollback and security gaps before touching Defender.
regedit > File > Export (Export range: All)Before changing anything, create a rollback path and stage your replacement protection.
- Enable and create a system restore point from an elevated PowerShell session:
The restore point captures system settings so you can revert Defender-related changes.
- Export a full registry backup so you can restore keys if a later registry edit goes wrong. Open
regeditas Administrator, select Computer at the top of the tree, then choose File > Export, set Export range to All, and save the.regfile to a safe location off the server.
- Download the installer for your chosen third-party enterprise antivirus (for example Symantec Endpoint Protection, CrowdStrike Falcon, SentinelOne, or Trend Micro Deep Security) and copy it to the server - but do not install it yet. You install it later in the step that closes the security gap.
Enable-ComputerRestore -Drive "C:"
Checkpoint-Computer -Description "Before Defender Disable" -RestorePointType "MODIFY_SETTINGS"
Get-ComputerRestorePoint | Select-Object -Last 1Never disable Defender without a replacement AV staged - the window between removing Defender and installing the new agent is a real exposure that attackers can exploit quickly. System restore points are limited on Server SKUs and may be disabled by policy; if Enable-ComputerRestore fails, rely on the registry export plus a full system/state backup instead.
Check current Defender status and features
Understand which Defender components are installed and running before changes.
Record a baseline so you can confirm the change worked and revert if needed.
- List installed Defender-related Windows features.
- List Defender services and their start type.
- Read the current real-time protection preferences.
Run the commands below in an elevated PowerShell session. In the feature output, look for InstallState : Installed on Windows-Defender-Features. In the service list, the antivirus service is WinDefend.
Get-WindowsFeature -Name *Defender*
Get-Service -Name *Defender* | Select-Object Name, Status, StartType
Get-MpPreference | Select-Object DisableRealtimeMonitoring, DisableBehaviorMonitoring, DisableIOAVProtectionSave or screenshot this output. You will compare against it after the disable/removal to confirm the process completed. Get-MpPreference only works while the Defender PowerShell module is present - once you fully uninstall Defender in Method 1, this cmdlet will no longer be available.
Method 1 - Uninstall Defender with PowerShell (recommended)
Completely remove Defender when no third-party AV needs Defender for Endpoint.
This is the most thorough method and prevents conflicts with a replacement AV. It removes the antivirus engine, GUI, PowerShell cmdlets, services, and drivers.
Open PowerShell as Administrator and run the uninstall. Use -Restart to reboot automatically, or -Remove to defer the restart to a maintenance window:
After the server restarts, verify removal. Get-WindowsFeature should report InstallState : Removed, and querying the WinDefend service should return nothing or an error that the service does not exist.
# Automatic restart:
Uninstall-WindowsFeature -Name Windows-Defender-Features -Restart
# Or defer the restart to a maintenance window:
Uninstall-WindowsFeature -Name Windows-Defender-Features -Remove
# After reboot, verify:
Get-WindowsFeature -Name Windows-Defender-Features
Get-Service -Name WinDefend -ErrorAction SilentlyContinueA restart is required to complete removal - plan for the reboot. This method fully removes Defender; do not use it on servers that rely on Microsoft Defender for Endpoint sensor functionality, since removing the antivirus platform can break EDR. Use passive mode (Method 3) in that scenario instead.
Method 2 - Disable via Group Policy
Turn off Defender across domain servers without uninstalling it.
Computer Configuration > Administrative Templates > Windows Components > Microsoft Defender AntivirusUse this when you cannot uninstall Defender or need consistent configuration across multiple servers. This disables protection but leaves the feature installed.
- Open the Local Group Policy Editor by running
gpedit.msc. - Navigate to Computer Configuration > Administrative Templates > Windows Components > Microsoft Defender Antivirus.
- Double-click Turn off Microsoft Defender Antivirus, set it to Enabled, and click OK.
- Open the Real-time Protection subfolder and set these policies to Enabled: Turn off real-time protection, Turn off behavior monitoring, and Turn off process scanning.
- Apply immediately with
gpupdate /force, then verify withGet-MpPreference.
gpupdate /force
Get-MpPreference | Select-Object DisableRealtimeMonitoring, DisableBehaviorMonitoringOn current Windows Server builds, tamper protection and Microsoft's changes to the "Turn off Microsoft Defender Antivirus" behavior mean this policy may be ignored or not fully disable the engine. In a domain, apply the policy at the OU level for consistent configuration across the server fleet rather than editing each server locally.
Method 3 - Registry modification for advanced control
Apply granular Defender settings or passive mode where other methods fail.
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows DefenderUse the registry when you need specific control or when other methods do not work. Confirm you completed the registry export from the backup step first.
- Open Registry Editor as Administrator with
regedit. - Navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender. Create the Windows Defender key if it does not exist. - Create these DWORD (32-bit) values set to
1:DisableAntiSpyware,DisableAntiVirus,DisableRealtimeMonitoring. - For servers running Microsoft Defender for Endpoint, instead navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protectionand create a DWORDForceDefenderPassiveModeset to1. This keeps Defender for Endpoint working while disabling local scanning. - Restart the server, then verify the value after reboot.
# Restart to apply:
Restart-Computer -Force
# After reboot, verify:
Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name DisableAntiSpywareIncorrect registry edits can make a server unbootable - always export the registry first (see the backup step). On newer Windows Server builds, DisableAntiSpyware is ignored because Microsoft deprecated it in favor of tamper protection; if the value has no effect, use passive mode (ForceDefenderPassiveMode) or fully uninstall via Method 1. Do not set both DisableAntiVirus and passive mode on the same server - choose one intent.
Alternative - remove Defender via Server Manager GUI
Achieve the same uninstall result using the graphical wizard.
Server Manager > Manage > Remove Roles and Features > FeaturesThis produces the identical result to the PowerShell uninstall in Method 1, using the GUI.
- Open Server Manager and choose Manage > Remove Roles and Features.
- Click Next through the wizard to the Features page.
- Uncheck Windows Defender Features and its sub-components: GUI for Windows Defender, Windows Defender, and Windows Defender PowerShell Module.
- Click Next, then Remove. The wizard prompts for a restart.
- After restart, verify removal with
Get-WindowsFeature.
Get-WindowsFeature -Name Windows-Defender-FeaturesChoose either this GUI method or Method 1 - do not run both. The end state is the same; this is only easier for administrators who prefer not to use the command line. A restart is required to finish removal.
Install and configure the replacement antivirus
Close the security gap immediately after disabling Defender.
Install your staged enterprise antivirus right after disabling Defender to minimize the exposure window.
- Install your chosen product (for example Symantec Endpoint Protection, CrowdStrike Falcon, SentinelOne, or Trend Micro Deep Security) following the vendor's documentation.
- Confirm its service is running.
- Test detection with the EICAR test file, which is a harmless standard test string - real-time protection should quarantine it on write.
- Configure real-time scanning, scheduled scans, application exclusions, and reporting/alerting per your organization's policy.
Get-Service | Where-Object {$_.DisplayName -like "*antivirus*" -or $_.DisplayName -like "*endpoint*"}
Invoke-WebRequest -Uri "https://www.eicar.org/download/eicar.com.txt" -OutFile "C:\temp\eicar.txt"Create C:\temp first if it does not exist, or change the output path. If the EICAR file is not caught, the new agent's real-time protection is not active - resolve this before considering the server protected. Some corporate proxies block the EICAR download; if so, use your vendor's own test procedure instead.
Verify complete removal and system security
Confirm Defender is off and the server is protected and stable.
Run a final verification pass to confirm Defender is gone (or disabled), the replacement AV is registered, and the server is stable.
- Confirm no Defender services are running and no Defender features remain.
- Check the registered antivirus in the Security Center namespace - it should list your new product, not Windows Defender.
- Review top processes to catch any AV-related CPU or memory spikes.
- Review the System event log for Defender-related errors.
Get-Service | Where-Object {$_.Name -like "*Defender*" -or $_.Name -like "*WinDefend*"}
Get-WindowsFeature | Where-Object {$_.Name -like "*Defender*"}
Get-WmiObject -Namespace "root\SecurityCenter2" -Class AntiVirusProduct | Select-Object displayName, productState
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 ProcessName, CPU, WorkingSet
Get-EventLog -LogName System -Source "*Defender*" -Newest 10 -ErrorAction SilentlyContinueThe root\SecurityCenter2 namespace is present on Server with the Desktop Experience; on Server Core it may be unavailable, so rely on the service/feature checks there. Document this change and the verification commands in your server maintenance checklist so other administrators understand the security posture. If you used Method 4 passive mode, expect Defender services to still exist by design.
Confirming Defender Is Disabled and Replacement Protection Is Active
After completing your chosen method and restarting, the goal is a server where Microsoft Defender Antivirus is no longer scanning and a supported replacement is actively protecting the system - not just an absence of Defender. How you confirm success depends on which method you used.
If you uninstalled Defender (Method 1 or the Server Manager GUI), Get-WindowsFeature -Name Windows-Defender-Features should report InstallState : Removed, and Get-Service -Name WinDefend -ErrorAction SilentlyContinue should return nothing because the service no longer exists. This is a clean removal: the antivirus engine, GUI, drivers, and the Defender PowerShell cmdlets are all gone.
If you disabled Defender via Group Policy (Method 2) or the registry (Method 3), the feature stays installed but protection is off. Get-MpPreference | Select-Object DisableRealtimeMonitoring, DisableBehaviorMonitoring should show True for the settings you configured. Note that on newer builds tamper protection and platform changes can cause some legacy registry keys (notably DisableAntiSpyware) to be ignored, so always confirm the effective state with Get-MpPreference rather than trusting the registry value alone. If you set ForceDefenderPassiveMode, Defender is intentionally left installed in passive mode for Defender for Endpoint.
Regardless of method, the security check that matters most is your replacement AV. Get-WmiObject -Namespace "root\SecurityCenter2" -Class AntiVirusProduct | Select-Object displayName, productState should list your third-party product - not Windows Defender - as the registered antivirus, and the EICAR test file from Step 7 should be detected and quarantined immediately. Finally, review recent System event logs and top processes to confirm the change was clean and the new AV is not causing CPU or memory contention.
- For an uninstall:
InstallState : Removedand noWinDefendservice. For a disable:DisableRealtimeMonitoring(and other configured values) returnTruefromGet-MpPreference. In all cases,root\SecurityCenter2shows your third-party AV as the active product, the EICAR file is caught, and System event logs show no Defender errors - only informational disable/removal entries. Get-MpPreferencestill showsFalseafter a GROUP Policy or registry change (often tamper protection or a legacy key being ignored on newer builds);root\SecurityCenter2still lists Windows Defender or shows no active product; the EICAR test file is not detected (replacement AV real-time protection is off or not installed); or WinDefend still runs after an uninstall (restart not applied). Treat an undetected EICAR file as an unprotected server and remediate before leaving the system in service.- Expected output from Get-WindowsFeature after a successful uninstall and restart.
- Expected Get-MpPreference output when Defender is disabled but still installed.
- root\SecurityCenter2 should list your third-party product instead of Windows Defender. Product name will match your chosen vendor.
- Expected error after uninstall - confirms the Defender service was removed.
Troubleshooting
DisableAntiSpyware registry value is ignored and Defender real-time protection stays on
Cause: On Windows Server 2016 and later, tamper protection and newer platform builds cause the client to ignore the DisableAntiSpyware value; Microsoft has deprecated relying on it to turn Defender off.
Do not rely on DisableAntiSpyware on current builds. Either fully remove the feature with Uninstall-WindowsFeature -Name Windows-Defender-Features -Restart (Method 1), or disable via Group Policy (Method 2). If tamper protection is enabled, disable it first through your management console, then re-apply the policy and run gpupdate /force.
Uninstall-WindowsFeature fails or Defender services still appear after the command
Cause: The uninstall requires a restart to fully remove components, drivers, and services; running the command with -Remove defers that restart, so components remain until the server reboots.
Reboot the server, then re-verify with Get-WindowsFeature -Name Windows-Defender-Features (expect InstallState : Removed) and Get-Service -Name WinDefend -ErrorAction SilentlyContinue (expect no service). If it still fails, check pending Windows Update or servicing operations and retry after they complete.
Server is left with no active protection during the change window
Cause: Defender was disabled or removed before the replacement antivirus was installed and confirmed active, leaving an exploitable security gap.
Have the third-party AV installer staged before touching Defender, and install it immediately after disabling. Confirm protection with Get-WmiObject -Namespace "root\SecurityCenter2" -Class AntiVirusProduct | Select-Object displayName, productState and validate detection using the EICAR test file before returning the server to normal duty.
Group Policy shows Defender disabled but Get-MpPreference values are not True
Cause: The policy has not refreshed on the client, or a higher-priority domain GPO is overriding the local policy setting.
Run gpupdate /force and re-check Get-MpPreference | Select-Object DisableRealtimeMonitoring, DisableBehaviorMonitoring. In a domain, use gpresult /r to confirm which GPO wins, and set the Defender policy at the correct OU level so it applies to the target servers.
Registry edit makes the server behave unexpectedly or you need to revert
Cause: Incorrect DWORD names, wrong hive path, or missing registry backup before editing under HKLM\SOFTWARE\Policies\Microsoft\Windows Defender.
Restore the registry export you created before editing (regedit > File > Import), or delete the specific DisableAntiSpyware/DisableAntiVirus/DisableRealtimeMonitoring values you added and restart. Always confirm the exact key path before creating values.
Frequently asked questions
Should I uninstall Defender or just disable it on Windows Server?
Microsoft recommends fully uninstalling Microsoft Defender Antivirus on servers that use a third-party antivirus and do not need Defender for Endpoint, using Uninstall-WindowsFeature -Name Windows-Defender-Features -Restart. Disabling via Group Policy or registry keeps the components installed and is best when you must manage many servers centrally or preserve Defender for Endpoint.
Why is DisableAntiSpyware ignored via registry on newer builds?
On Windows Server 2016 and later, Microsoft deprecated the DisableAntiSpyware value and tamper protection prevents it from turning Defender off, so setting it has no effect. Use full removal with Uninstall-WindowsFeature or Group Policy instead.
Does disabling Defender break Microsoft Defender for Endpoint?
Fully uninstalling Defender Antivirus can break Defender for Endpoint, which relies on the antivirus component for some detections. If you use Defender for Endpoint, set ForceDefenderPassiveMode = 1 under HKLM\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection so Endpoint keeps working while local scanning is disabled.
How do I re-enable Windows Defender after disabling it?
If you disabled Defender via Group Policy or registry, reverse those settings (set the policy back to Not Configured/Disabled or remove the DWORD values) and restart. If you uninstalled the feature, reinstall it with Install-WindowsFeature -Name Windows-Defender-Features -Restart.
Is it safe to run a server without any antivirus after removing Defender?
No. Removing Defender without an active replacement creates a critical security gap that attackers can exploit within minutes. Always install and confirm your third-party antivirus is running before returning the server to production.
What is Defender passive mode and when should I use it?
Passive mode keeps Microsoft Defender Antivirus installed but stops it from performing active real-time scanning, allowing a third-party AV or Defender for Endpoint to lead. Use it when you run Defender for Endpoint alongside another antivirus by setting ForceDefenderPassiveMode = 1 in the registry.





