Audit and Tighten Microsoft Defender Antivirus Exclusions Across Intune, Group Policy and Local Lists
Find every Defender Antivirus exclusion, replace the risky broad ones with narrow entries, remove them where they were set, and stop local additions coming back.

Advertising disclosure: this article includes partner links. KBY may earn a commission if you sign up or buy through one, at no extra cost to you. How we make money.
Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.
To audit Microsoft Defender Antivirus exclusions, export every exclusion list your management tools deploy, read the merged list each device actually uses with Get-MpPreference, and compare both with Microsoft’s list of folders, extensions and processes that should never be excluded. Then replace each broad entry with a narrow one (a full file path, a full process path or a contextual exclusion) before you remove it at its source. By default a local administrator’s exclusions merge with the ones Intune, Configuration Manager or Group Policy deploy, so deleting an entry in one place often leaves it alive in another. Finish by turning on Disable local admin merge and checking that tamper protection covers the exclusion lists, so the cleaned list stays clean.
#The problem with exclusion lists that only grow
Microsoft describes every exclusion as a protection gap. An excluded file, folder or process is skipped by scheduled scans, on-demand scans and real-time protection, and the effect reaches beyond scanning. Exclusions also weaken features that depend on the antivirus engine, such as file and certificate indicators of compromise. A process exclusion also stops network protection and attack surface reduction (ASR) rules from inspecting traffic or enforcing rules for that process.
An exclusion added for a slow build server or an app that was flagged once tends to outlive the reason for it, and a list built that way can end up holding C:\Temp, a bare .ps1 extension or powershell.exe. Microsoft’s guidance is to review and audit exclusions periodically and keep a record of why each one exists.
Defender already excludes operating system files on every supported Windows version, and on Windows Server 2016 and later it adds automatic exclusions for installed server roles. Those built-in and automatic exclusions arrive with security intelligence updates and don’t appear in the standard exclusion lists. A custom entry that duplicates one adds only another line to maintain.
#How the pieces fit on a device
Defender keeps custom exclusions in separate lists, and the audit has to read all of them:
- Path exclusions cover a file or a whole folder, including its subfolders.
- Extension exclusions cover every file with that extension anywhere on the device.
- Process exclusions skip the files a process opens. The process’s own executable is not excluded unless it also has a path entry.
- Contextual exclusions narrow a path exclusion to a process, a scan type, a scan trigger or a file-or-folder type. They are Windows-only, and the Windows Security app doesn’t support them.
Those lists can be filled from Intune endpoint security Antivirus policies (also editable in the Microsoft Defender portal), Configuration Manager, Group Policy, any MDM through the Defender Policy CSP, and locally through PowerShell, WMI or the Windows Security app. Intune merges the exclusions from every assigned policy into one superset on each device. Local changes by administrators then merge with the managed lists. Where they conflict, Group Policy takes precedence, and Microsoft notes that exclusion settings from Intune or Configuration Manager overwrite conflicting Group Policy or PowerShell settings at startup.
So the list on any one device is the sum of several sources, and Get-MpPreference shows that sum without saying which source contributed each line. The audit therefore reads both: each management source, and a sample of devices.
Rendering diagram...

#Step by step: inventory, classify, then remove
- Export the managed lists. In the Intune admin center, open Endpoint security > Antivirus, select each policy that uses the Microsoft Defender Antivirus exclusions profile (or sets exclusions in a Microsoft Defender Antivirus profile), choose Edit next to Configuration settings and use Export on each list to save it as a .csv file. Do the same review for any GPO that configures exclusions and for Configuration Manager antimalware policies. These exports are also your rollback copy, so keep them with the change record.
- Read the effective list on a sample of devices. In an elevated PowerShell session, Microsoft’s own one-liner lists every custom exclusion by type:
1$p = Get-MpPreference; 'ExclusionExtension','ExclusionPath','ExclusionProcess' | ForEach-Object { $t = $_; $p.$t | ForEach-Object {[pscustomobject]@{Type=$t; Value=$_}} } | Format-Table -AutoSizeSwap
Format-Table -AutoSizeforExport-Csv -Path .\exclusions-before.csv -NoTypeInformationto keep a dated copy. Pick a few devices from each role: workstations, file servers, SQL and IIS hosts, build agents. An entry that appears in none of the exports was most likely added locally, or by a tool you haven’t exported yet. - Classify every entry. Mark an entry for replacement if it matches Microsoft’s exclusions to avoid. On Windows that includes
%systemdrive%,C:\Temp,C:\Users\,%Windir%\Temp, program folders such asC:\Program Files\Contoso\, extensions such as.exe,.dll,.ps1,.bat,.zipand.js, and processes such aspowershell.exe,cmd.exe,wscript.exe,mshta.exe,svchost.exeand the Office apps. Also mark bare file names (a name likeFilename.exedoesn’t reliably exclude anything), image-name process exclusions (they match any process with that name, including one run from removable media), entries that use%TEMP%(the service resolves it as LocalSystem, so it meansC:\Windows\TEMP), and one list shared by several server workloads. - Write the narrow replacement first. For each marked entry that still serves a real need, add its replacement before you remove anything. Turn an image name into a full path such as
C:\Program Files\Contoso\agent.exe. Turn an extension exclusion into a path with a wildcard, such asC:\Example\*.test. Where only one process needs the exclusion, use a contextual entry such asC:\Example\*.test\:{Process:"C:\Program Files\Contoso\agent.exe"}; the backslash before the colon is required. For a false positive, Microsoft points to submitting the file for analysis, or a custom allow indicator as a temporary suppression. - Remove the broad entry where it was defined. In Intune, edit the policy, select the entry and choose Remove, then save. For a local entry, use
Remove-MpPreference, which removes only the values you name:1Remove-MpPreference -ExclusionPath "C:\Temp"Never use
Set-MpPreferencefor this: it overwrites every existing exclusion of that type with the values you pass. Stop if the entry turns out to come from a policy you don’t own, and hand it to that policy’s owner rather than adding a local workaround. - Stop local additions. In an Intune Microsoft Defender Antivirus profile, set Disable local admin merge. Only the managed lists then apply. This also overrides controlled folder access settings, protected folders and allowed apps set by local administrators, so check those first.
Work one device role at a time, so a performance regression points to one change. The same staged approach suits ASR rules, covered in moving Defender ASR rules from Audit to Block in Intune rings.
#How to prove the cleanup took effect
Rerun the Get-MpPreference listing and compare it with your before file. The removed entries should be gone and the replacements present. If an entry you removed in Intune is still listed, it is coming from somewhere else.
To test a specific path, MpCmdRun.exe -CheckExclusion -Path needs Defender platform 4.18.2111-5.0 or later and an elevated command prompt in the platform folder:
1MpCmdRun.exe -CheckExclusion -Path C:\Data\Test
2C:\Data\Test [\Device\HarddiskVolume1\Data\Test] is not excluded. Exit code is 1.An “is excluded” result (exit code 0) only means some entry covers the path. A parent-folder exclusion makes every file below it report as excluded, and the tool doesn’t say which entry matched. To confirm that scanning has returned for a path or extension, place the harmless EICAR test file there. Defender should detect it. If it doesn’t, an exclusion still applies. The EICAR test doesn’t validate process exclusions, because those depend on which process opens the file.
Every policy change also leaves a trace. Event 5007, “The antimalware platform configuration changed”, is written to Applications and Services Logs > Microsoft > Windows > Windows Defender > Operational with the old and new values:
1Get-WinEvent -FilterHashtable @{ LogName='Microsoft-Windows-Windows Defender/Operational'; Id=5007; StartTime=(Get-Date).AddDays(-1) } | Select-Object TimeCreated, MessageFinally, check that tamper protection now guards the lists. Read TPExclusions under HKLM\SOFTWARE\Microsoft\Windows Defender\Features. A value of 1 means the requirements are met and the exclusions are tamper protected; 0 means they aren’t. Read these values only; never change them.
#What goes wrong during an exclusion cleanup
- An entry removed in Intune is still on the device. Another assigned policy, a GPO or a local administrator still sets it, because lists merge rather than replace each other. Find the other source.
Get-MpPreferenceshows no exclusions at all on a device you know has them.HideExclusionsFromLocalAdminsis on, which hides exclusions fromGet-MpPreferenceand Registry Editor without removing them. Read the list from the management source instead.- A local script wiped every path exclusion. It used
Set-MpPreference, which overwrites the whole list. Restore from the before file withAdd-MpPreference. - A new folder exclusion has no effect on a reparse point subfolder. Folder exclusions don’t cover reparse point subfolders, which need their own entry, and one created after the Defender service started isn’t recognised until Windows restarts.
- A contextual exclusion never applies. Two values of the same ScanType, ScanTrigger or PathType keyword in one entry are combined with AND, so
{ScanTrigger:OnAccess,ScanTrigger:OnDemand}can never match. Split it into two entries. TPExclusionsstays at 0. The device is co-managed by Configuration Manager and Intune (ManagedDefenderProductType7 withEnrollmentStatus3), isn’t managed only by Intune or only by Configuration Manager, is below platform 4.18.2211.5, or doesn’t haveDisableLocalAdminMergeenabled.
A device that never reports exclusion changes may not be talking to the service at all; fixing a Defender for Endpoint device stuck onboarding or inactive covers that case.

#Access control for the exclusion lists
With the default merge behaviour, any local administrator can add exclusions with PowerShell or WMI and they apply alongside the managed ones. That makes the exclusion list part of the privilege model. Disable local admin merge removes that route, and tamper protection then blocks changes to the managed lists. Its requirements are platform 4.18.2211.5 or later, DisableLocalAdminMerge enabled, the Defender for Endpoint sensor running, and a device managed only by Intune or only by Configuration Manager, with exclusions deployed from that tool. You don’t need to turn tamper protection off to push new exclusion settings from Intune or Configuration Manager.
Who can edit the policies matters as much. In Intune, changing tamper protection needs permissions equivalent to the built-in Endpoint Security Manager role, so keep that role, and edit rights on the Antivirus policies, to the security team rather than every device administrator. Keep two points in mind when weighing an exclusion against an indicator. Antivirus exclusions don’t apply to endpoint detection and response, so an excluded file can still raise an EDR alert. And on Windows, a file allowed by a Defender Antivirus exclusion is allowed before any block or warn file indicator is checked, so an exclusion can override a block indicator for the same file.
#How to roll back a removal that broke something
If a workload slows down or an app starts getting flagged after an entry goes, restore that one entry, not the whole old list. In Intune, edit the policy and add the value back, or use Import with the .csv you exported in step 1; the file takes one header line (such as ExcludedExtensions) and one value per line. For a local entry, add back only what you removed:
1Add-MpPreference -ExclusionPath "C:\Temp"Confirm event 5007 on the device and the entry in the Get-MpPreference listing. Then find what needed it, write the narrow replacement and remove the broad entry again. If Disable local admin merge caused the break, because a team relied on local exclusions or controlled folder access allowed apps, move those entries into a managed policy before you turn local merging back on. Turning it back on reopens the local route for every administrator.
#Keeping the exclusion list short from now on
- Run the
Get-MpPreferencelisting on the same sample devices each quarter and diff it against the last export. - Treat an unexpected event 5007 as a reason to look. Microsoft says it may be the result of malware.
- Require a reason, an owner and a review date for every new Intune exclusion, and keep separate exclusion lists per server workload, such as IIS and SQL Server.
- Check
TPExclusionson new devices as they are enrolled.
Removals that reopen a performance problem go back through the rollback above. Anything that needs %systemdrive%, a system process or an executable extension excluded goes to the security team as a risk decision, not a ticket.
About this page
Credited to
Dates
Published
Sources
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Related labs
Calculators and what-if tools that go with this article.
Recommended reading
More from KBY that goes with this article.
Discover more
Graduate Learning
Ops Playbook
- PlaybookInstall the Configuration Manager Client During Windows Autopilot With Intune Co-Management Settings
- PlaybookMigrate Group Policy to Intune With Group Policy Analytics Before Moving Autopilot to Entra Join
- PlaybookSet Up Windows Autopilot Device Preparation With Enrollment Time Grouping in Intune
- PlaybookConfigure the Autopilot Enrollment Status Page to Block Desktop Use Until Required Apps Install
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Engineering insights, direct to you.
Receive the latest Systems Engineering tutorials, production guides, Engineering Labs and operational best practices.

Comments
Add a thoughtful note on Audit and Tighten Microsoft Defender Antivirus Exclusions Across Intune, Group Policy and Local Lists. Comments are checked for spam and held for moderation before appearing.