Skip to content
  • There are no suggestions because the search field is empty.

Office 365 Whitelisting script

In case manually implementing the whitelisting does not suit your needs you can run a script to add the required items.

The instructions described in Whitelisting for O365 article can also be implemented by running the script we prepared via the Exchange Online PowerShell modules.

Please make sure that our settings do not interfere with the ones that are currently configured on your end before the script execution. 

Step 1: Download the script file

Download the .ps1 file of the script below:


Step 2: Connect to PowerShell online

You need to connect to PowerShell online as described in the following  Microsoft guide.


Alternatively, you can use the below command:
Connect-ExchangeOnline -UserPrincipalName admin@domain.onmicrosoft.com

Where admin@domain.onmicrosoft.com should be replaced with your admin account with global admin permissions required to execute the script.

Step 3: Execute the script

Change the working directory to the one where you have the script saved i.e downloads folder:

cd C:\Users\%USERNAME%\Downloads

Run the script via the below command:

.\whitelist-office365.ps1 -email admin@domain.onmicrosoft.com -xTestPhish <yourValue>

Where:
1. "admin@domain.onmicrosoft.com" is the global admin email with sufficient permissions to execute the script
2. "-xTestPhish <yourValue>" adds the custom desired text to the X-TestPhish header that our simulation campaigns contain by default.

Our Phishing simulations use the X-TestPhish header by default, you can insert your custom text to the X-TestPhish header as "<yourValue>" 

Note that in case you do not wish to add custom text to the header you can run the script without mentioning the "-xTestPhish <yourValue>" which will lead to using the default parameter

The above value can be changed in Wizer admin later if required


Executing the script by running the below command will assign the default parameter:

.\whitelist-office365.ps1 -email admin@domain.onmicrosoft.com

Troubleshooting Tips

  • Error Messages: If you encounter any errors, double-check the domain formatting and permissions.

  • Permission Issues: Ensure your account has the required permissions to create transport rules.

  • Connection Issues: Verify that you are connected to Exchange Online.