Advanced Office 365 Message Encryption (OME) Usage Example with a custom branding template!



Dear Microsoft 365 Friends,


This example is about using OME (Office Message Encryption) with a custom template. Whenever an email is sent to a specific domain ( in my example), the email should be encrypted and equipped with the custom template. The recipient can then decrypt the content with an OTP (one-time pass code).

To work with Advanced Office 365 Message Encryption you need the right licenses. You can find this information in the following link:


We start our configuration in PowerShell. With the PowerShell we can create a new template, but only with the appropriate permissions. For example, to work with New-OMEConfiguration we need the necessary permission. I will show you later how to determine which permissions are needed to run a specific cmdlet. For this demo I used the "Organization Management" Role Group. This is certainly not ideal but absolutely fine for this demo.


The necessary permissions can be configured in the Microsoft 365 Defender portal.



I used the PowerShell ISE for this configuration. But you are also very welcome to use Visual Studio Code, just as you wish.
Please start with the following steps to begin the deployment (the Hashtags are comments): Note: In the following template I create, I make only a few adjustments. Of course you can also work with a logo, specify different text, etc.


#The first two lines have nothing to do with the configuration, but make some space below in the blue part of the ISE.
Set-Location C:\


#Install the module
Install-Module -Name ExchangeOnlineManagement -AllowClobber -Force -Verbose


#Sometimes the module must be imported
Import-Module ExchangeOnlineManagement


#Connect to exchange
Connect-ExchangeOnline -UserPrincipalName


#Did it work


#Get the OME branding template
$ome = Get-OMEConfiguration | fl *


#All the settings


#Check the cmdlets
Get-Command -Name *OME*


#Find the permissions required to run a cmdlet
Get-ManagementRoleEntry -Identity *\New-OMEConfiguration | ft -AutoSize


#Create an OME branding template
New-OMEConfiguration -Identity ""


#Background color (blue)
Set-OMEConfiguration -Identity "" -BackgroundColor "#0000ff"


#Text next to the sender's name and email address
Set-OMEConfiguration -Identity "" -IntroductionText "has sent you a secure message."


#To disable authentication with Microsoft, Google, or Yahoo identities for this custom template
Set-OMEConfiguration -Identity "" -SocialIdSignIn $false


#To enable authentication with a one-time pass code for this custom template
Set-OMEConfiguration -Identity "" -OTPEnabled $true


#Optional set expiry days
Set-OMEConfiguration -Identity "" -ExternalMailExpiryInDays 7


#For more Infos check:


#Check the details
$customome = Get-OMEConfiguration -Identity "" | fl *


#All the settings


So the template is created. Now we need to set up a new mail flow rule in Exchange Online. So that when an email is sent to a specific domain ( in my example), the email is encrypted and our template is used. Please navigate to Exchange Online.




Now we test if it works. In Outlook we create an email and send it to an email address.



The email has arrived and looks like this. As we can see our template has been used, among other things we can see the custom text we added with PowerShell.



I hope this article was helpful for you? Thank you for taking the time to read this article.


Best regards, Tom Wechsler


P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github!


0 Replies