Jan 30 2021 11:22 PM
Hi Exchange Friends,
This article is about how to set up an email address policy using the Exchange Management Shell. Please start with the following steps to begin the "journey" (the Hashtags are comments):
#Please start the EMS (Exchange Management Shell)
#Let's check all policies
Get-EmailAddressPolicy
#Create a new email address policies
New-EmailAddressPolicy -Name "Zurich Office" -IncludedRecipients AllRecipients -ConditionalStateorProvince "ZH" -EnabledEmailAddressTemplate "SMTP:%g.%s@contosotom.ch", "smtp:zh-%g.%s@contosotom.ch"
#Now we use the new policy
Update-EmailAddressPolicy –Identity "Zurich Office"
#Let's check all policies
Get-EmailAddressPolicy
#A bit more infos
Get-EmailAddressPolicy | Format-List Name,Priority,Enabled*,RecipientFilterType,IncludedRecipients,Conditional*
#Check the default policy
Get-EmailAddressPolicy –Identity Default* | Format-List Name,Priority,Enabled*,RecipientFilterType,IncludedRecipients,Conditional*
#A new policy with more specifications
New-EmailAddressPolicy -Name "Luzern Managers" -RecipientFilter "(StateOrProvince-eq 'LU') -and (Title -like '*Director*' -or Title -like '*Manager*')" -EnabledEmailAddressTemplate "SMTP:%g.%s@contosotom.ch", "smtp:lu_managers.%g.%s@contosotom.ch"
#Now we use the new policy
Update-EmailAddressPolicy –Identity "Luzern Managers"
#Update an existing policy
Set-EmailAddressPolicy -Identity "Zurich Office" -ConditionalStateOrProvince @{Add= "ZHDWNT"}
#Let's check the configuration
Get-EmailAddressPolicy –Identity "Zurich Office" | Format-List Name,Priority,Enabled*,RecipientFilterType,IncludedRecipients,Conditional*
#To remove a policy
Remove-EmailAddressPolicy –Identity "Luzern Managers"
Remove-EmailAddressPolicy –Identity "Zurich Office"
I hope this article was useful. Best regards, Tom Wechsler
P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler