How to add files and folders to Windows Defender exclusion list
Windows Defender Antivirus sometimes flags legitimate files or folders as threats (false positives). To prevent this, you can add those files or folders to the Defender exclusion list, so they are ignored during scans. Here is a complete and detailed guide on how to do this using both the Windows Security interface and PowerShell.
Adding Exclusions via Windows Security Interface
Open Windows Security
Click the Start menu and type Windows Security.
Select Windows Security from the search results to open the app.
Navigate to Virus & Threat Protection
In the Windows Security window, click on Virus & threat protection.
Access Virus & Threat Protection Settings
Scroll down to the Virus & threat protection settings section.
Click on Manage settings.
Open Exclusions Settings
Scroll down to the Exclusions section.
Click on Add or remove exclusions.
Add a New Exclusion
Click the Add an exclusion button (a plus sign).
Choose the type of exclusion you want to add:
File: To exclude a specific file.
Folder: To exclude an entire folder and its contents.
File type: To exclude all files with a specific extension.
Process: To exclude files opened by a specific process.
Select the File or Folder
Navigate to the file or folder you want to exclude.
Select it and confirm.
Verify the Exclusion
The selected item will now appear in the exclusions list.
You can remove it later by selecting it and clicking Remove if needed.
This method is straightforward and suitable for most users who prefer a graphical interface.
Adding Exclusions Using PowerShell
For advanced users or administrators managing multiple machines, PowerShell provides a flexible way to add exclusions.
Open PowerShell as Administrator
Right-click the Start button and select Windows Terminal (Admin) or PowerShell (Admin).
Use Defender Module Cmdlets
The key cmdlets for managing exclusions are:
Add-MpPreference
– Adds an item to the exclusion list.Remove-MpPreference
– Removes an item from the exclusion list.Set-MpPreference
– Overwrites the exclusion list.
Add a Folder Exclusion
powershellAdd-MpPreference -ExclusionPath "C:\Path\To\Folder"
Add a File Exclusion
powershellAdd-MpPreference -ExclusionPath "C:\Path\To\File.exe"
Add a File Extension Exclusion
powershellAdd-MpPreference -ExclusionExtension ".ext"
Add a Process Exclusion
powershellAdd-MpPreference -ExclusionProcess "C:\Path\To\Process.exe"
Check Current Exclusions
powershellGet-MpPreference | Select-Object -Property ExclusionPath, ExclusionExtension, ExclusionProcess
Important Notes:
Folder exclusions apply to all files and subfolders unless a subfolder is a reparse point (symbolic link), which must be excluded separately.
Using
Set-MpPreference
will overwrite existing exclusions, so use it with caution.Variables like
%USERPROFILE%
are not interpreted; use explicit full paths.
Best Practices and Considerations
Use exclusions sparingly: Excluding files or folders reduces protection for those items and can expose your system to risks.
Verify false positives: Only exclude files or folders you are sure are safe.
Use explicit paths: Avoid environment variables in exclusions to ensure they work correctly.
Audit exclusions regularly: Review your exclusion list periodically to remove unnecessary entries.
By following this guide, you can effectively add files and folders to the Windows Defender exclusion list to prevent false positives and ensure smooth operation of trusted software or files on your Windows system.