Windows Defender has a feature called “Exclusions” that allows you to block files from being quarantined or removed based on their file extension. Here we explain how to list and add exclusions using PowerShell in order for them to work properly, without the need of manually running Windows Defender.
There are many ways to remove Windows Defender from your computer, but the “uninstall windows defender powershell windows 10” is a quick and easy way. You can use PowerShell to uninstall Windows Defender.
We like to remove Windows Defender Antivirus exclusions. The problem is that there are a lot of exclusions, and when we go to the Microsoft virus & threat protection settings, it takes a lot of time to remove them manually. That’s because you can’t select multiple exclusions and remove them. An excellent approach to remove Windows Defender exclusions is with PowerShell. So let’s look at the fastest way to clear Windows Defender Antivirus exclusions with PowerShell.
Microsoft Defender is an antivirus program.
Microsoft Defender is an antivirus program. (formerly Windows Defender) is Microsoft Windows virus and threat protection software. Microsoft Defender is an antivirus program. is available in Windows 10, Windows 11, and in versions of Windows Server. It comes default with the Windows operating system. It can be run next to your non-Microsoft antivirus/antimalware product, in active mode, passive mode, and disabled mode.
A list of all the exclusions appears when you go to the Windows Defender Antivirus exclusions. There isn’t a select-all option or a checkbox to pick the exclusions, which is unfortunate. Instead, each exclusion has just one button: Remove.
Exclusions for Windows Defender Antivirus should be obvious. Script in PowerShell
Before you begin, make sure the files are in the correct location. On the (C:) drive, we propose creating two folders:
Download and save the PowerShell script Clear-WindowsDefenderExcl.ps1 to the C:scripts folder. The logs will be exported to the C:temp folder by the script.
To avoid issues while executing the script, make sure the file is unblocked. More information may be found in the article. When executing a PowerShell script, an error occurs because it is not securely signed.
You may also copy and paste the code below into Notepad. Put it in the C:scripts folder with the name Clear-WindowsDefenderExcl.ps1.
ExclusionPath, ExclusionProcess, and ExclusionExtension # linked with Windows Defender Antivirus are cleared using a PowerShell script. # Begin the transcript $Logs = “C:tempClear-WindowsDefenderExcl.txt” $Logs = “C:tempClear-WindowsDefenderExcl.txt” Start-Transcript -Append -Force $Logs # Preferences for Windows Defender Get-MpPreference $x # If ($x.ExclusionPath -ne) is true, get the exclusion path. $NULL) foreach I in $x.ExclusionPath) Write-Host(“============================================================================================ I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I $ $x.ExclusionPath.Count) else Write-Host(“=============================================================================================== Write-Host(,,,,,,,,,,,,,,,, “There are no ExclusionPath entries. I’m going to skip “( ) If ($x.ExclusionProcess -ne $NULL), get the exclusion process. foreach I in $x.ExclusionProcess) Write-Host(“============================================================================================ I Write-Host($i) Remove-MpPreference -ExclusionProcess Host-Write( “==================================================================================================”) Write-Host(“Total ExclusionProcess entries I’m going to skip “( ) If ($x.ExclusionExtension -ne $NULL), get the exclusion extension. Write-Host(“=========================================================================================================== Host-Write (“Removing the following ExclusionExtension entries:”) $x.ExclusionExtension) foreach I in $x.ExclusionExtension) -ExclusionExtension Remove-MpPreference I I I I I I I I I I I I I I $ $x.ExclusionExtension.Count) else Write-Host(“================================================================================================ Write-Host(,,,,,,,,,,,,,,,, “There are no ExclusionExtension entries. I’m going to skip “( ) # Synopsis Write-Host(“================================================”) Write-Host(“SUMMARY”) $x.ExclusionPath.Count, “ExclusionPath entries removed.” Write-Host($x.ExclusionPath.Count, “ExclusionPath entries deleted.” $x.ExclusionProcess.Count, “ExclusionProcess entries removed.” Write-Host($x.ExclusionProcess.Count, “ExclusionProcess entries deleted.” $x.ExclusionProcess.Count, “ExclusionExtension entries removed.” Write-Host($x.ExclusionProcess.Count, “ExclusionExtension entries deleted.” $x.ExclusionPath.Count + $x.ExclusionProcess.Count + $x.ExclusionExtension.Count), “Total entries removed”) Write-Host(($x.ExclusionPath.Count + $x.ExclusionProcess.Count + $x.ExclusionExtension.Count), “Total entries deleted”) Write-Host(“”) Write-Host(“Done.”) Stop-Transcript
- Line 5: Change the route to the transcript log.
Clear the exclusions in Windows Defender Antivirus. Script in PowerShell
To remove Windows Defender Antivirus exclusions, follow these steps:
- PowerShell should be run as an administrator.
- Change the scripts folder’s path.
- To remove all exclusions from Windows Defender Antivirus, run the PowerShell script.
- Wait for the PowerShell script to finish.
PS C:> cd c:scripts PS C:scripts> .Clear-WindowsDefenderExcl.ps1
Note: The removed exclusions items will be shown in the Windows PowerShell console, along with a summary of the overall count. Also, since a transcript is included in the PS script, the output will be shown in a log.
This is a sample of what it looks like after executing the PowerShell script Clear-WindowsDefenderExcl.ps1.
Remove the exclusions from Windows Defender Antivirus.
You may always open the Clear-WindowsDefenderExcl.txt file in the C:temp folder to see the log output.
Check to see whether the script removed all of the exclusions from Windows Defender Antivirus.
Windows Defender should be turned off.
Read these articles if you wish to deactivate or remove Windows Defender:
Conclusion
You learnt how to use PowerShell to remove Windows Defender Antivirus exclusions. Eliminating all exclusions using PowerShell is significantly quicker than manually removing them via the Graphic User Interface (GUI). Focus on other chores while using the script.
Did you find this article to be interesting? You may also be interested in Windows’ Secure Wipe hard disk and solid state drive. Don’t forget to subscribe to our newsletter and share this content.
The “windows defender powershell commands” is a command-line tool that allows users to clear Windows Defender Antivirus exclusions. The tool can be executed with either PowerShell or Command Prompt.
Related Tags
- permanently disable windows defender powershell windows 10
- check windows defender exclusions powershell
- powershell defender exclusions
- windows defender powershell scripts
- powershellwindows defender status