Use Set-Mailbox to add email alias based on Get-Mailbox Filter

logo-powershellThe company who I work for are currently in the process of migrating away from Exchange on premise and over to Office 365. Now, 95% of our ActiveDirectory records are set to inherit the mail recipient policy – the other 5% have been excluded for one reason or another.. As the technical lead on the project, I had to come up with a way to add the new/required email address to all mail accounts prior to migration. Which is there this little PowerShell script was born.. I must admit, I have somewhat of a love/hate relationship with PowerShell, I understand its powerful, and that things have to change.. Its just taking me sometime to get used to it.. Anyway, this is what I have so far, it may well be that it could be tweaked somewhat, so if you have any suggestions please do let me know!

Steps involved

  1. Search Exchange for all mailboxes with the inherit flag unticked
  2. Build the new email address using Firstname.Lastname
  3. If the first name and last name fields are blank in AD, build the address using the display name.
  4. Strip any spaces out of the name, and replace with full stops
  5. Finally – add the new mail address to the Exchange Object

Mike Hudson

Mike Hudson is a Infrastructure Analyst living and working in Kingston Upon Hull. With extensive experience in Microsoft and Apple technologies, ranging from desktop OS’s to Server OS’s and hardware. By day working as part of an infrastructure team, and by night ridding the world of IT issues through blog posts..

%d bloggers like this: