How to add to Windows Defender EXCLUSIONS ..

Steve

Rebuilding slowly but getting there ..
Staff member
.. So you want Defender to stop eating your files in a clean install, well here is the quick fix

IMPORTANT NOTE = Those are single ' not " in the cmd line!

To add a drive to Windows Defender exclusions using the command line, open PowerShell as administrator and use the Add-MpPreference cmdlet with the -ExclusionPath parameter, specifying the full drive letter path you want to exclude; for example, Add-MpPreference -ExclusionPath 'D:\' would exclude the entire D drive from scans.
Key points:
  • Command: Add-MpPreference -ExclusionPath '<drive_letter>:\'
  • Example: Add-MpPreference -ExclusionPath 'D:\'

Here is the 2 paths I use in my .cmd, 1 is a repeat for all my drives, the last is for dControl.exe

THIS is drives only which is awesome, add more drives with each line
Code:
powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'C:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'D:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'E:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'F:\' -Force

For a specific file ( like DefenderControl.exe )
Code:
powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionProcess 'dControl.exe' -Force

Have Fun!
 
Last edited:
Ok, I have had enough of DEFENDER taking files from my USB drive, so I updated my list above to have all drives added to exclusions list, here it is

create a new txt file rename it to whatever.cmd if you want to run it on your own, I named mine RUN_DefenderExclusionsForAllDrives.cmd so it will get ran in Last releases.

Code:
powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'C:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'D:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'E:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'F:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'G:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'H:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'I:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'J:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'K:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'L:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'M:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'N:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'O:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'P:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'Q:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'R:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'S:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'T:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'U:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'V:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'W:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'X:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'Y:\' -Force

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath 'Z:\' -Force
 
Last edited:
Back
Top