How to Exclude a Folder in Windows Defender from a Batch File

For those of you who still like scripts like in the good old days, here’s  post for Windows Defender.

The command to exclude a folder in Windows Defender is shown below. The call to PowerShell may be done from a batch file in the following way:

powershell  -Command Add-MpPreference -ExclusionPath "C:\FolderToExclude"

You could chain several of these one after the other or call the PoweerShell script file instead:

PowerShell c:\scripts\mypowershellfile.ps1