Automating Microsoft 365 preservation source setup
The following page provides details on how to use an optional PowerShell script, O365PIPSetup.ps1, to automate Azure configuration steps needed to enable the Microsoft 365 Relativity preservation data source. The script handles several of the required Azure configuration tasks, including:
- Creating a new Azure AD application for Relativity Preservation.
- Configuring application identifiers, redirect URIs, and other required properties.
- Assigning the required Microsoft Graph API permissions for data preservation.
- Automating granting admin consent to the required permissions.
- Assigning the Compliance Administrator and Exchange Administrator roles to the Application Registration.
- Creating the Service Principal for the registered application.
- Assigning the eDiscovery Case Admin permissions in Purview.
- The script does not replace the official setup steps, but can be used as a companion to streamline configuration. For more information, see Microsoft 365 Preservation Data Source Setup.
- The script does not automate certificate creation or upload. You must still create and upload the required certificate to the Azure AD application manually. For more information, see Generate certificate.
- You must create the new Preservation Data Source in your Relativity workspace. For more information, see Creating the Microsoft 365 data source.
Prerequisites
Before running the script, ensure you have:
- An Azure AD Global Administrator or equivalent permissions.
- Access to the Azure tenant where the Relativity Preservation Data Source will be configured.
Run PowerShell script
Complete the following steps to run the PowerShell script:
- Download O365PIPSetup.ps1 and save to a secure location.
- Open PowerShell.
- Run the script, for example: .\O365PIPSetup.ps1
- The script will prompt you to provide an application name and create a Service Principal name.
The script will prompt you to login to Microsoft three times, once for each PowerShell module being used. Login to the Microsoft tenant where you intend to do the setup.
- Once the script is complete, it will provide you with the create Client ID, Tenant ID, and Domain. Confirm that the Azure application has been created and configured.

- Manually upload the certificate to the application. For more information, see Generate certificate.
- Create the Preservation data source using the Client ID, Tenant ID, and Domain provided from the script. For more information, see Creating the Microsoft 365 data source.
- Validate the credentials. For more information, see Validate preservation hold credentials.
Validate the PowerShell script
After running the script and uploading your certificate, validate the following:
- The Azure AD app appears under App Registrations.
- Required API permissions are present and granted.
- The certificate is successfully uploaded.
- App Registration is assigned the Compliance Administrator and Exchange Administrator roles.
- Relativity Preservation can connect to Microsoft 365 using the new data source.
- This script is intended as a convenience tool and is not mandatory.
- Updates may be required as Microsoft Graph or Azure API requirements evolve.