How To Remove A Specific Domain From All Exchange 2013 /2010 Mailboxes

The code below will show you how to remove a specific domain from all users mailboxes.

The code was tested on Exchange 2010 and Exchange 2013.


if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null )


"Exchange Online – Find Mailb...
"Exchange Online – Find Mailboxes With Specific Domain – Learn IT And DevOps Daily"

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010


foreach($i in Get-Mailbox -ResultSize Unlimited) {

$i.EmailAddresses |

?{$_.AddressString -like ‘*’} | %{

Set-Mailbox $i -EmailAddresses @{remove=$_}