Add Defender Exclusions with PowerShell (Add-MpPreference)
Skip antivirus scanning for a build folder or a trusted process using the Defender module's Add-MpPreference.
01Command
$ Add-MpPreference -ExclusionPath 'D:\dev\build' ; Add-MpPreference -ExclusionProcess 'node.exe'02What it does
Real-time scanning of huge build outputs (node_modules, obj/bin, Docker layers) is a classic cause of slow development machines, and exclusions are the documented remedy. Exclusions can be scoped by path, extension, or process name, and Get-MpPreference shows what is currently set. Each exclusion weakens protection — Microsoft recommends narrow, specific paths rather than whole drives, since malware in an excluded folder is invisible to Defender.
03Risk
04Undo
$ Remove-MpPreference -ExclusionPath 'D:\dev\build' ; Remove-MpPreference -ExclusionProcess 'node.exe'05Sources
- Add-MpPreference (Defender module)Evidence: Documents the Add-MpPreference cmdlet and its -ExclusionPath / -ExclusionProcess parameters.
- Configure and validate exclusions for Microsoft Defender Antivirus scansEvidence: Documents path, extension and process exclusions, and warns that exclusions create a gap in protection and should be as specific as possible.
Last verified: 2026-09-17 · Category: Security & Privacy
06Related solutions
Search inside text files and logs with regex, returning file, line number and match.
Create or update a .zip from any files or folder contents straight from PowerShell.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.