How to Add Windows Defender Exclusions Manually and via PowerShell
This guide explains two ways to whitelist files or folders in Windows Defender: a step‑by‑step manual method through the Windows Security UI and a PowerShell command‑line approach for adding or removing exclusion paths.
Some users asked how to add a whitelist entry to Windows Defender, so this article provides two practical methods.
Method 1: Manually add an exclusion in Windows Defender
Open the Windows Security Center, select "Virus & threat protection", then click "Virus & threat protection settings" and choose "Manage settings". Temporarily turn off real‑time protection (it will re‑enable automatically). Scroll to the bottom, click "Add or remove exclusions", then click "Add an exclusion" and choose either a file or a folder to exclude.
Method 2: Use PowerShell to add or remove exclusions
You can run PowerShell commands to add or remove paths from the exclusion list. Replace the highlighted path (e.g., C:\ ) with the desired file or folder.
To add an exclusion:
powershell "try {$null = icim MSFT_MpPreference @{ExclusionPath = @('C:\'); Force = $True} Add -Namespace root/Microsoft/Windows/Defender -EA 1} catch {$host.SetShouldExit($_.Exception.HResult)}"To remove an exclusion:
powershell "try {$null = icim MSFT_MpPreference @{ExclusionPath = @('C:\'); Force = $True} Remove -Namespace root/Microsoft/Windows/Defender -EA 1} catch {$host.SetShouldExit($_.Exception.HResult)}"You can save these commands in a .cmd file for easy reuse. A batch script that adds all drives to the whitelist is also available for download.
Warm reminder : Antivirus software is essential; if a program is falsely flagged, temporarily disable the protection rather than uninstalling the antivirus, and remember to re‑enable it afterward.
Additional links to related technical articles are provided at the end of the original page.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.