1 Open an elevated PowerShell.
2 Type the command you want to use below into the elevated PowerShell, and press Enter. (see screenshots below)
(Add file exclusion)
Add-MpPreference -ExclusionPath "<Full path of file>" -Force
(Remove file exclusion)
Remove-MpPreference -ExclusionPath "<Full path of file>" -Force
Substitute <Full path of file> in the commands above with the actual full path of the file (ex: “C:\Windows\notepad.exe”) you want to add or remove as an exclusion.
3 You can now close the elevated PowerShell if you like.