fireguy1125
asked on
Remove SMTP Address from all Exchange 2010 User Mailboxes Using Powershell
I need a script that will remove a specific SMTP address from all of our users mailboxes. The address is username@migration.company .com and was used during a coexistence/migration scenario between GroupWise and Exchange. The username is specific to the person, so something like an if contain "migration.company.com" statement then delete SMTP address. I'm an amateur to PowerShell so would need something cut and paste like.
Thanks in advance!
Thanks in advance!
You can try the following. Copy and paste into Notepad and save as SMTPRemove.ps1.
Go to Exchange Managment Shell and change to the location where you saved the script. type .\SMTPRemove.ps1 and press Enter
Go to Exchange Managment Shell and change to the location where you saved the script. type .\SMTPRemove.ps1 and press Enter
#########################################################
# This Script remove post-migration SMTP Addresses
cls
$mailboxes=Get-Mailbox -ResultSize unlimited
foreach($mailbox in $mailboxes)
{
for($i=($mailbox.EmailAddresses.count)-1; $i -ge 0; $i--)
{
$address=$mailbox.EmailAddresses[$i]
$addressString=$address.addressString
if($addressString -like "*migration.company.com")
{
$mailbox.EmailAddresses.removeat($i)
}
}
$mailbox|set-mailbox -EmailAddresses $mailbox.EmailAddresses
}
ASKER
NRhode -thanks so much, however unfortunately I'm unable to use any 3rd party utilities
gkrew - i've tried your script in our lab and seems to be exactly what we need. - Is there any way we can have the results of which mailboxes had the address removed from into a csv/txt file?
gkrew - i've tried your script in our lab and seems to be exactly what we need. - Is there any way we can have the results of which mailboxes had the address removed from into a csv/txt file?
Just in case for after you run the script if those emails were created by a policy you would have to remove/disable that policy otherwise it might update and put the addresses back onto the mailboxes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
The script was apply with success.
How to execute in all items do exchange 2010 SP3?
tks
The script was apply with success.
How to execute in all items do exchange 2010 SP3?
tks
Could just use ADModify: http://buenoflex.com/archives/242