Set Windows Defender exclusions with PowerShell
To exclude folders, files or file extensions in scanning by Windows Defender, you can use PowerShell. It’s recommended to use by administrators. With this PowerShell script (command) you can easily set exclusion for the Windows Defender. It is useful sometime and help to improve the performance.
Open PowerShell (or terminal) as administrator and the next command:
Add-MpPreference -ExclusionPath “C:\Datafolder”
If you use Windows Server, you can also save a file as "setExclusions.ps1" on your local drive, for example, in "c:\Scripts\setExclusions.ps1", and execute it with PowerShell or terminal. On desktop Window you should enable running scripts at first. You can do it with another PowerShell command:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
But I don’t advise you to modify it, because not only your scripts can be executed. Especially with exclusions in Windows Defender 🙂