Skip to content

Windows Defender on Windows Server

This page is for Windows Server hosts that run SenseOn as the endpoint antivirus and EDR. It applies if the server is separately onboarded to Microsoft Defender for Endpoint (MDE), and also if it is not. The page tells you why Windows Security does not show SenseOn as an enabled antivirus product on these hosts. It also gives the supported procedure to stop Windows Defender Antivirus so that it does not run together with SenseOn. For a server that is onboarded to MDE, the procedure is passive mode. For a server that is not onboarded, the procedure is to remove the feature fully.

When you install SenseOn, the installation does not put Windows Defender Antivirus into passive mode. It also does not stop Windows Defender Antivirus in a different way. If you do nothing, the two engines stay active and continue to scan. Microsoft guidance says that two active antivirus engines on a server "impact performance and is not supported" (Microsoft Defender Antivirus compatibility with other security products).

This is not a protection gap. The two engines continue to detect. The cost is:

  • performance (the engines scan each file open and each process start two times)
  • duplicate or contradictory detections
  • an unsupported configuration

💡 Scope: This page applies to Windows Server 2016 and later. On these versions, Windows Defender Antivirus is the Windows-Defender feature. Windows Server 2012 R2 has an older antimalware component with a different name. The steps on this page do not apply to that component. If you must have guidance for a 2012 R2 host, contact SenseOn support.

âš  Is this server onboarded to Microsoft Defender for Endpoint? Do not remove the feature. The MDE sensor operates only if the Windows-Defender feature is present. This is also true when the feature is in passive mode. Do not use the removal steps. Use Servers onboarded to Microsoft Defender for Endpoint instead. If you are not sure which procedure applies to a server, contact SenseOn support.


Why Windows Security does not show SenseOn as enabled

On Windows 10/11, a third-party antivirus product registers itself with the Windows Security Center (WSC). Windows Security then shows that product as the active antivirus. Microsoft Defender Antivirus automatically goes into disabled mode. If the device is also onboarded to Microsoft Defender for Endpoint, Microsoft Defender Antivirus goes into passive mode instead.

Windows Server does not have this registration mechanism. Windows Security on Server editions has no "security providers" list. Thus no antivirus product can register itself there or show as enabled. This includes SenseOn. This behaviour is expected and is not a fault. It is true for all antivirus products on Windows Server, not only for SenseOn.

To find the protection status of a server, look at the SenseOn console or the status of the local agent. Do not use Windows Security for this.

Check the current state

Before you make a decision, find if Defender Antivirus is already inactive. Also find if the server is onboarded to Microsoft Defender for Endpoint. Run these commands:

Get-MpComputerStatus | Select-Object AMRunningMode, AntivirusEnabled, RealTimeProtectionEnabled, IsTamperProtected
Get-Service Sense, WinDefend -ErrorAction SilentlyContinue | Select-Object Name, Status
Reading Meaning
AMRunningMode = Normal Defender Antivirus is active. The two engines run. Action is necessary.
AMRunningMode = Passive Mode or EDR Block Mode Defender is already not the primary antivirus. SenseOn is the primary. No action is necessary.
cmdlet fails, no WinDefend service, no MsMpEng.exe process Defender Antivirus is already uninstalled. No action is necessary.
Sense service present and running The server is onboarded to Microsoft Defender for Endpoint. Do not remove the feature. Use Servers onboarded to Microsoft Defender for Endpoint instead.

Servers onboarded to Microsoft Defender for Endpoint

Do not remove the Windows-Defender feature on these hosts. The MDE sensor operates only if the feature is present. This is also true when the feature is in passive mode. Instead, use a policy registry key to force Defender Antivirus into passive mode. Open PowerShell as an Administrator. Elevation is necessary to write to this registry path.

💡 Set this before onboarding where possible. After a server is onboarded to Microsoft Defender for Endpoint, tamper protection lets Defender Antivirus change to active mode. Tamper protection does not let it change back to passive mode. Thus this registry key no longer has an effect. If you control the onboarding sequence, set the registry key first.

Before you run these commands, look at the value of IsTamperProtected in Check the current state. If the value is True, first set tamper protection to off for the device in the Microsoft Defender portal. If you do not, Restart-Service stops with an access denied error:

New-Item 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection' -Force | Out-Null
Set-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection' -Name ForceDefenderPassiveMode -Type DWord -Value 1
Restart-Service WinDefend
Get-MpComputerStatus | Select-Object AMRunningMode

If you do not want to restart the service directly, you can reboot the server instead of Restart-Service. The expected value of AMRunningMode is Passive Mode. Keep the server onboarded to Microsoft Defender for Endpoint. The onboarding causes no problem with SenseOn.

For passive mode, you must also exclude some binaries from the scans that SenseOn does. These are the binaries of Microsoft Defender Antivirus and of Microsoft Defender for Endpoint. Add these binaries as exclusions in the SenseOn endpoint protection configuration. Add them together with the exclusions that Antivirus and EDR Exclusions already recommends for Defender.

âš  Verify against your own tenant before relying on this. This procedure changes the behaviour of Defender through policy. It does not remove a Windows feature. Before you deploy it, compare it with the configuration of your tenant. Examine the tamper protection configuration and the Defender for Endpoint policy configuration. If you get results that you did not expect, contact SenseOn support.

Servers not onboarded to Microsoft Defender for Endpoint

A manual disable of Windows Defender on a server is not a supported configuration. This applies when you change its service start type through Group Policy or the registry. If a server is not onboarded to Microsoft Defender for Endpoint, the supported procedure is to remove the Windows-Defender Windows feature fully.

Removing the feature

  • Save a copy of the PowerShell script at this link to a location that you select.
  • Open PowerShell as an Administrator.
  • Go to the directory that contains the script.
  • First, do a dry run. The dry run shows what the script does but changes nothing:
.\manage_windows_defender_feature.ps1 -Action Remove -WhatIf
  • Then run the script to make the changes:
.\manage_windows_defender_feature.ps1 -Action Remove

Before the script removes the feature, it reports:

  • the OS version of the server
  • the current status of the Windows-Defender feature
  • the service status of the SenseOn agent

On Windows Server 2016, the script also removes the separate Windows-Defender-Gui feature.

💡 Restart: A restart is necessary to complete the removal. Until the restart, Windows Defender Antivirus can continue to run. Windows marks the feature for removal, but it does not fully remove the service and the files until the reboot. Thus the two engines can be active during that time.

To let the script restart the server automatically, add -Restart. Alternatively, make sure that a reboot occurs by other means (your patch schedule or a manual reboot). By default, the script does not restart the server.

The script writes a log with timestamps to %TEMP%\SenseOnDefenderFeature\DefenderFeature.log. The script also exits with a status code. Thus a deployment tool can find if the script was successful, and it is not necessary to parse the console output:

Exit code Meaning
0 Success, or the feature was already in the requested state (nothing to do)
2 Not running with Administrator rights
10 The Remove action failed
11 The Revert action failed

Deploying via Group Policy

You can safely deploy the script as a Group Policy computer startup script for these reasons:

  • The script does not show a prompt.
  • The script does not restart the server unless you give -Restart.
  • On a host where the feature is already removed, the script exits quickly and makes no changes.

Thus you can safely keep the script linked for an unlimited time. This is the same as the computer startup script pattern used for deploying SenseOn itself. If you deploy the script without -Restart, the removal completes only at the next reboot of the server. That reboot occurs when your usual patch cycle causes it.

powershell.exe -ExecutionPolicy Bypass -File manage_windows_defender_feature.ps1 -Action Remove

Startup scripts run as SYSTEM. SYSTEM already has the Administrator rights that are necessary for the script.

Reverting

To undo a removal that you did before, run the script again with -Action Revert:

.\manage_windows_defender_feature.ps1 -Action Revert -WhatIf
.\manage_windows_defender_feature.ps1 -Action Revert

âš  Revert needs internet access. By default, the revert action gets the feature payload from Windows Update. On a server that has no internet access, add -Source instead. Point -Source to the sxs folder of a Windows Server install image:

.\manage_windows_defender_feature.ps1 -Action Revert -Source D:\sources\sxs

Before you rely on this, make sure that it works in your own environment. This is most important on air-gapped servers and on servers with strict firewall rules.

Choosing to keep Defender Antivirus active

You can make the decision to keep Windows Defender Antivirus active on a server and not remove it or force passive mode. Microsoft does not support this configuration, but it is available if you select it deliberately. It is not a protection gap. The two engines continue to detect.

For those hosts, set Protection level to Run alongside another AV. Do not use Automated response or Alert only. This setting is in Device Configuration (refer to Configuring Antimalware). Also add mutual exclusions:

  • In Defender, exclude the SenseOn install paths, the SenseOn ProgramData paths, and the SenseOn processes. Antivirus and EDR Exclusions gives the list.
  • In the SenseOn configuration, exclude the Defender paths (C:\Program Files\Windows Defender\, C:\ProgramData\Microsoft\Windows Defender\) and the Defender processes (MsMpEng.exe, MpCmdRun.exe).

We recommend that you keep a record of this decision in your change management process, because the decision is different from the supported Microsoft configuration.

Verifying

After you make the change, do a check of the result.

For a server where you removed the feature, run this command after a restart:

Get-WindowsFeature -Name Windows-Defender

After a removal, the value of Installed must be False. After a revert, the value must be True.

For an MDE-onboarded server that you put into passive mode, run this command:

Get-MpComputerStatus | Select-Object AMRunningMode

The value of AMRunningMode must be Passive Mode or EDR Block Mode. All other values mean that the two engines are still active.

In the two cases, also make sure that the SenseOn agent still reports normally. Use the SenseOn console or the local service status of the agent.

Finding affected hosts across your estate

To find hosts where Defender Antivirus is still active, open Hunt Lab. Start a new query. Then run the query that follows. The query looks for MsMpEng.exe in process telemetry from the last day and groups the results by hostname:

SELECT
    lower(_hostname) AS hostname,
    count() AS occurrences
FROM
    endpoint_process
WHERE
    lower(name) = 'msmpeng.exe'
    AND _time_observed >= toUnixTimestamp(subtractDays(now(), 1)) * 1000
GROUP BY
    lower(_hostname)
ORDER BY
    occurrences DESC

Put _hostname and name in lower(). Do not compare them or group on them directly. The letter case is different between hosts. It also changes with how a telemetry path recorded the process name.

MsMpEng.exe is the core Defender engine. Thus this query also finds usual Windows 10/11 workstations where Defender is the only antivirus by design. No action is necessary for those workstations. Before you treat a host as affected, compare the returned hostnames with your server inventory.

Each server in the list either runs the two engines or is already in passive mode by design. A server that is not onboarded to Microsoft Defender for Endpoint cannot be in passive mode. Thus the list is conclusive for those hosts. For MDE-onboarded hosts, examine each host individually. Use the AMRunningMode check in Check the current state.