Remove Domain Suffix for All Users

Tested on Exchange 2010

To remove a specific domain suffix for all users, use the following PS1

# Get all mailboxes
$mailboxes = get-mailbox;

# Loop through each mailbox
foreach ($mailbox in $mailboxes) {

$emailaddresses = $mailbox.emailaddresses;

#Loop through each SMTP address found on each mailbox
for ($i=0; $i -lt $emailaddresses.count; $i++) {

# Change the domain name below to what you want to remove
if ($emailaddresses[$i].smtpaddress -like “*domaintoremove.com*”) {

# Remove the unwanted email address
$badaddress = $emailaddresses[$i];
$emailaddresses = $emailaddresses – $badaddress;
$mailbox | set-mailbox -emailaddresses $emailaddresses;

}

}

}

Reference: http://hkeylocalmachine.com/?p=133

Advertisements
Categories: Microsoft, Office 365 | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: