Recently I had a customer need to remove an old domain from 365 as they no longer needed it.  Using the portal you’d have to remove any alias individually so here’s a bit of powershelgl to automate this.
Here’s the bits you need to connect to 365 via Azure Powershell if you’re in Europe (in Order)
1) $UserCredential = Get-Credential
2) $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection
3) Import-PSSession $Session
4) $Records = Get-mailbox -ResultSize Unlimited| where {$_.emailaddresses -like “smtp:*”} | Select-Object DisplayName,@{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_ -like “smtp:*”}}}

foreach ($record in $Records)
write-host “Removing Alias” $record.EmailAddresses “for” $record.DisplayName
Set-Mailbox $record.DisplayName -EmailAddresses @{Remove=$record.EmailAddresses}

Connect on

Simon Treadaway

This blog is maintained by Simon Treadaway.Simon is a Senior Infrastructure Architect working in London, UK.
Connect on
Remove all aliases for a domain in Office 365

Leave a Reply

Your email address will not be published. Required fields are marked *