Review and manage Microsoft Defender exclusions on Windows

List what Defender never scans with Get-MpPreference, and add or remove exclusions with Add-MpPreference / Remove-MpPreference.

WindowsantivirusdefenderhardeningHigh risk
Run Get-MpPreference | Select-Object -ExpandProperty ExclusionPath to review current path exclusions before adding or removing any.

01Command

Command
$ Get-MpPreference | Select-Object -ExpandProperty ExclusionPath

02What it does

Exclusions are a security posture decision hiding in an antivirus preference: anything excluded is invisible to real-time protection, and malware deliberately drops into excluded paths. ExclusionProcess differs subtly from ExclusionPath — it excludes files opened by that process, wherever they live. Auditing the existing lists first is the step everyone skips, yet it is the fastest way to understand why a scan missed something.

03Risk

RiskHigh risk
RequirementsRun PowerShell as Administrator; tamper protection may block changes
!Warning: Every exclusion weakens real-time protection — keep paths narrow (no drive roots), and re-check the list regularly since exclusions persist silently.

04Undo

Undo
$ Remove-MpPreference -ExclusionPath "C:\Dev\build"

05Sources

Last verified: 2026-09-17 · Category: Security & Privacy