diff --git a/windows/keep-secure/configure-exclusions-windows-defender-antivirus.md b/windows/keep-secure/configure-exclusions-windows-defender-antivirus.md index 7fff80a386..154cce92a0 100644 --- a/windows/keep-secure/configure-exclusions-windows-defender-antivirus.md +++ b/windows/keep-secure/configure-exclusions-windows-defender-antivirus.md @@ -12,7 +12,7 @@ localizationpriority: medium author: iaanw --- -# Exclude files and processes from Windows Defender AV scans +# Configure file and folder exclusions in Windows Defender AV scans **Applies to:** @@ -27,22 +27,25 @@ author: iaanw **Manageability available with** - Group Policy -- System Center Configuration Manager - PowerShell - Windows Management Instrumentation (WMI) +- System Center Configuration Manager - Microsoft Intune - Windows Defender Security Center You can exclude certain files, folders, processes, and process-modified files from being scanned by Windows Defender AV. The exclusions apply to [scheduled scans](scheduled-catch-up-scans-windows-defender-antivirus.md), [on-demand scans](run-scan-windows-defender-antivirus.md), and [always-on real-time protection and monitoring](configure-real-time-protection-windows-defender-antivirus.md). -Changes made via Group Policy to the exclusion lists will show in the lists in the [Windows Defender Security Center app](windows-defender-security-center-antivirus.md#exclusions). +Changes made via Group Policy to the exclusion lists **will show** in the lists in the [Windows Defender Security Center app](windows-defender-security-center-antivirus.md#exclusions). However, changes made in the Windows Defender Security Center app **will not show** in the Group Policy lists. -However, changes made in the Windows Defender Security Center app will not show in the lists in the Group Policy settings. +You can add, remove, and review the lists for exclusions in [Group Policy](#gp), [System Center Configuration Manager, Microsoft Intune, and with the Windows Defender Security Center app](#man-tools). -You can add, remove, and review the lists for exclusions in Group Policy, System Center Configuration Manager, Microsoft Intune, and with the Windows Defender Security Center app. +You can also [use PowerShell cmdlets and WMI to configure the exclusion lists](#ps), although you will need to use several different cmdlets. -You can also use PowerShell cmdlets and WMI to configure the exclusion lists, although you will need to use several different cmdlets. +By default, local changes made to the lists (by users with administrator privileges) will be merged with the lists as defined (and deployed) by Group Policy, Configuration Manager, Intune, PowerShell, or WMI. The Group Policy lists will take precedence in the case of conflicts. You can [configure how locally and globally defined exclusions lists are merged](configure-local-policy-overrides-windows-defender-antivirus.md#merge-lists) to disable this setting. +PowerShell can be used to [validate that your exclusion lists are working as expected](#validate). + + ## Use Group Policy to configure exclusion lists **Use Group Policy to configure file extension exclusions:** @@ -66,7 +69,10 @@ You can also use PowerShell cmdlets and WMI to configure the exclusion lists, al  -**Use Group Policy to exclude specified paths or folders from scans:** +**Use Group Policy to exclude specified files or folders from scans:** + +>[!NOTE] +>The exclusion will apply to any file with the defined file name - regardless of its location. If a folder is defined in the exclusion, then all files and subdirectories under that folder will be excluded. 1. On your Group Policy management machine, open the [Group Policy Management Console](https://technet.microsoft.com/library/cc731212.aspx), right-click the Group Policy Object you want to configure and click **Edit**. @@ -81,7 +87,7 @@ You can also use PowerShell cmdlets and WMI to configure the exclusion lists, al 1. Set the option to **Enabled**. 2. Under the **Options** section, click **Show...** - 3. Enter each path or file on its own line under the **Value name** column. If you are entering a file, ensure you enter a fully qualified path to the file, including the drive letter, folder path, filename, and extesnsion. Enter **0** in the **Value** column for all processes. + 3. Enter each path or file on its own line under the **Value name** column. If you are entering a file, ensure you enter a fully qualified path to the file, including the drive letter, folder path, filename, and extension. Enter **0** in the **Value** column for all processes. 7. Click **OK**. @@ -89,8 +95,10 @@ You can also use PowerShell cmdlets and WMI to configure the exclusion lists, al **Use Group Policy to exclude files that have been used or modified by specified processes from scans:** ->[!NOTE] You can exclude files that are opened by specified processes from being scanned. The specified process won't be excluded - but any files that are opened by that process will be. If you need to exclude the process itself, [exclude it as a file](#exclude-paths-files). ->You can only exclude files modified by processes if the process is an executable. +>[!NOTE] +>You can exclude files that are opened by specified processes from being scanned. The specified process won't be excluded - but any files that are opened by that process (regardless of where they are or what they are named) will be excluded. If you need to exclude the process itself, [exclude it as a file](#exclude-paths-files). +>You can only exclude files modified by processes if the process is an executable. + 1. On your Group Policy management machine, open the [Group Policy Management Console](https://technet.microsoft.com/library/cc731212.aspx), right-click the Group Policy Object you want to configure and click **Edit**. @@ -105,16 +113,16 @@ You can also use PowerShell cmdlets and WMI to configure the exclusion lists, al 1. Set the option to **Enabled**. 2. Under the **Options** section, click **Show...** - 3. Enter each process on its own line under the **Value name** column. Ensure you enter a fully qualified path to the process, including the drive letter, folder path, filename, and extesnsion. The process must be an executable. Enter **0** in the **Value** column for all processes. + 3. Enter each process on its own line under the **Value name** column. Ensure you enter a fully qualified path to the process, including the drive letter, folder path, filename, and extension. The process must be an executable. Enter **0** in the **Value** column for all processes. 7. Click **OK**.  - + ## Use PowerShell cmdlets and WMI to configure exclusion lists -Excluding and reviewing file extensions, paths and files (including processes), and files opened by processes with PowerShell requires using a combination of four cmdlets and the appropriate exclusion list parameter. The cmdlets are all in the Defender module. +Excluding and reviewing file extensions, paths and files (including processes), and files opened by processes with PowerShell requires using a combination of four cmdlets and the appropriate exclusion list parameter. The cmdlets are all in the [Defender module](https://technet.microsoft.com/en-us/itpro/powershell/windows/defender/defender). There are three exclusion lists: - ExclusionExtension @@ -127,48 +135,111 @@ You can modify each of the lists with the following cmdlets: - Remove-MpPreference to remove or delete items from the defined list - Get-MpPreference to review the items in the list, either all at once with all other Windows Defender AV settings, or individually for each of the lists - -The format for the command is: - -```PowerShell - - -**Use PowerShell cmdlets to create a new list of file extension exclusions:** - - -1. Review the current list of exclusions: - -```PowerShell -Get-MpPreference - - -Set-MpPreference -ExclusionExtension -Add-MpPreference -ExclusionExtension -Remove-MpPreference -ExclusionExtension -``` - >[!IMPORTANT] ->Use the `Set-MpPreference` cmdlet to create a list. This will overwrite the existing list. ->Use `Add-MpPreference` to add items to the list, and `Remove-MpPreference` to remove or delete items from the list. ->Assigning `Get-MpPreference` to a variable and then querying `ExclusionExtension` will place the items from each instance of `Add-MpPreference` on its own line. Using `Get-MpPreference` on its own will place all items together. +>If you have created a list, either with `Set-MpPreference` or `Add-MpPreference`, using the `Set-MpPreference` cmdlet again will overwrite the existing list. + +The following matrix provides sample commands based on what you want to exclude, and whether you want to create a list, add to the list, or remove items from the list. + +
Configuration action | Type of exclusion | PowerShell command |
---|---|---|
Create or overwrite a list | File extensions that should be excluded from scans | +Set-MpPreference -ExclusionExtension ".extension1, .extension2, .extension3" |
Files (including processes) and paths that should be excluded from scans | +Set-MpPreference -ExclusionPath "c:\example, d:\test\process.exe, c:\test\file.bat" | |
Files opened by the specified processes (executables) | +Set-MpPreference -ExclusionProcess "c:\example\test.exe" | |
Add to a list | File extensions that should be excluded from scans | +Add-MpPreference -ExclusionExtension ".extension4, .extension5" |
Files (including processes) and paths that should be excluded from scans | +Add-MpPreference -ExclusionPath "d:\test, d:\example\file.png" | |
Files opened by specified processes (executables) | +Add-MpPreference -ExclusionProcess "f:\test\sample.exe" | |
Remove items from a list | File extensions that should be excluded from scans | +Remove-MpPreference -ExclusionExtension ".extension1, .extension4, .extension5" |
Files (including processes) and paths that should be excluded from scans | +Remove-MpPreference -ExclusionPath "c:\example, d:\example\file.png" | |
Files opened by specified processes (executables) | +Remove-MpPreference -ExclusionProcess "c:\example\test.exe" |