How to add files and folders to Windows Defender exclusion list

false-positive-virus

 

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

  1. Open Windows Security

    • Click the Start menu and type Windows Security.

    • Select Windows Security from the search results to open the app.

  2. Navigate to Virus & Threat Protection

    • In the Windows Security window, click on Virus & threat protection.

  3. Access Virus & Threat Protection Settings

    • Scroll down to the Virus & threat protection settings section.

    • Click on Manage settings.

  4. Open Exclusions Settings

    • Scroll down to the Exclusions section.

    • Click on Add or remove exclusions.

  5. 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.

  6. Select the File or Folder

    • Navigate to the file or folder you want to exclude.

    • Select it and confirm.

  7. 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.

  1. Open PowerShell as Administrator

    • Right-click the Start button and select Windows Terminal (Admin) or PowerShell (Admin).

  2. 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.

  3. Add a Folder Exclusion

    powershell
    Add-MpPreference -ExclusionPath "C:\Path\To\Folder"
  4. Add a File Exclusion

    powershell
    Add-MpPreference -ExclusionPath "C:\Path\To\File.exe"
  5. Add a File Extension Exclusion

    powershell
    Add-MpPreference -ExclusionExtension ".ext"
  6. Add a Process Exclusion

    powershell
    Add-MpPreference -ExclusionProcess "C:\Path\To\Process.exe"
  7. Check Current Exclusions

    powershell
    Get-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.

You might also like