IT Support and Managed IT Services : Glasgow | Edinburgh | Scotland

Recipient Policies in Office 365

If you’re here you’re possibly sad to be missing Exchange recipient policies in your Office 365 deployment. Unless you have a hybrid deployment or some other kind of synchronisation with an on-premises server you need to add aliases (proxy addresses) the hard way.

I pulled a few scripts I could find and tweaked to make them do my favoured firstname.lastname email address policies.

This is only worth doing if you have too many users to manually update via the GUI.

We found best plan was to add a department name to define the groups of users who will get different addresses. So megacorpeurope and megacorpus in my examples. This is also useful for applying further scripts, building address books etc.

Make sure all your user details are correct as that is what we’ll use to generate the proxy addresses.

We then need to run 2 batches of commands, 1 for each “department”. Create a test department with only 1 or 2 accounts in it before running this over hundreds of accounts.

$users1 = Get-Recipient -ResultSize Unlimited| Where {$_.Department -Match “megacorpeurope”}
foreach ($c in $users1) {$c.emailaddresses.Add(“smtp:$($c.FirstName+”.”+$c.LastName)@megacorpeurope.com”)}
$users1 | %{Set-Mailbox $_.Identity -EmailAddresses $_.EmailAddresses}

$users2 = Get-Recipient -ResultSize Unlimited| Where {$_.Department -Match “megacorpus”}
foreach ($d in $users2) {$d.emailaddresses.Add(“smtp:$($d.FirstName+”.”+$d.LastName)@megacorpeurope.com”)}
$users2 | %{Set-Mailbox $_.Identity -EmailAddresses $_.EmailAddresses}

Use these commands at your own risk! I’d recommend testing, testing and more testing before running over a large number of accounts on a live deployment.