Exchange Email Address Removal

Soldato
Joined
4 Dec 2002
Posts
3,983
Location
Bourne, Lincs
After some Exchange / Powershell help here.

We are in teh process of migrating up to Office 365 as part of that we have slimmed down the Accepted Domain lists in Exchange all fine and good.

However a lot of our accounts have email address from domains we have just removed and others from a while back.

I can run scripts to show me what email address people have, but is there a way to compare what email address people have, and if it is not in the accepted domains list they are removed from the user?

Have 1000+ mailboxes so doing it manually is not an option

Thanks

Kimbie
 
If you haven't done so already, Is it worth whacking your script output into excel do some analysis and find out exactly how big a problem you may have?

If it's 50 or less it may well take longer to create the script than to just have done it manually in the first place.
 
If you haven't done so already, Is it worth whacking your script output into excel do some analysis and find out exactly how big a problem you may have?

If it's 50 or less it may well take longer to create the script than to just have done it manually in the first place.

+1,

i wouldnt run any untrusted source app on mynetwork...a powershell script that you can understand (and test in a live like environment) is another matter.
 
I would start a search of the mailboxes with the domains you wish to remove, then you can decide on how to remove them.

I'd personally start with the following if you want to take this route.

Get-Mailbox | Where {$_.emailaddresses -match "Domain1.com|Domain2.com" | Select name....ect

Look at the listing, I would personally export as previously stated and just ensure that the filter applied above is good before making any changes.

Once that's done you can then do

$Mailboxes = Get-Mailbox | Where {$_.emailaddresses -match "Domain1.com|Domain2.com" | select-object -expandproperties alias

foreach ($mailbox in $Mailbox)
{
Set-Mailbox -emailaddresses "VaildEmailAddress1","ValidEmailAddress2" -primarysmtpaddress "DefaultEmailAddress"
}

The above will require some tweaking as the email address will need to be formatted for each user.

But I would suggest you maybe look into Address Policys and enabling it for all users or select users in OU's/groups or whatever takes your fancy.
 
Last edited:
Back
Top Bottom