To Add or Remove File Exclusion for Microsoft Defender Antivirus in PowerShell

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.

Original author:



您的电子邮箱地址不会被公开。 必填项已用*标注