Table of Contents
Problem
How to configure the malware scanner in Exchange Online Protection (EOP) to block non-executable document files such as pdfs, docs, and so on? On the interface can only add executables.
Solution
Malware Filter within EOP cannot this in the UI but rather in PowerShell. Perform below steps to block file based on extension using PowerShell:
- Login using a Global Admin account to Exchange Online via Windows PowerShell (Run as Admin):
Set-ExecutionPolicy RemoteSigned -Scope Currentuser $credential = get-credential $ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection Import-PSSession $ExchangeSession
- When you are prompted about changing the Execution Policy type A for Yes to All.
- Then modify this to include the extensions you want the block, for example the extensions must be in this format (separated by commas without spaces): “doc”,”docx”,”pdf” etc. Then when it is ready copy/paste it on the command line and press enter to execute:
Get-MalwareFilterPolicy -Identity default | select -Expand FileTypes; $FileTypesAdd += "pdf","doc","docx","xls"; Set-MalwareFilterPolicy -Identity default -EnableFileFilter $true -FileTypes $FileTypesAdd
Assumptions
- That the policy is the default Malware Filter policy labeled “default”; and that
- By performing this it will erase the previous list of executables so once this is complete simply log back into the UI and click the Add link, then select all to add all the executable extensions to your list. This way you will have all the executable and your new extensions in the list as desired.
- If MFA (Multi-Factor Authentication) enabled on that account? you need to use the specific MFA password provided for apps when you first configured MFA.