In Exchange if you delete an address policy or policy entry it will not remove the address from the users themselves.(this is by design)
This is not an issue if you just modify the address (that will get re-stamped with the modified address)
But if you want to remove already stamped addresses from all users in a domain here is the PS command.(2010 and 2007)
- get-mailbox |% {$a = $_.emailaddresses; $b = $_.emailaddresses; foreach ($e in $a) {if ($e.tostring() -match "DomainIWantToRemove.com") {$b -= $e;}}$_ | set-mailbox -emailaddresses $b}
Thanks Michael for the script.
Hi, I receive this error when trying
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power…tHelperRunspace:ExecutionCmdletHelperRunspace) [],
PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
But this worked:
$allmailboxes = get-mailbox
$allmailboxes |% {$a = $_.emailaddresses; $b = $_.emailaddresses; foreach ($e in $a) {if ($e.tostring() -match “DomainIWantToRemove.be”) {$b -= $e;}}$_ | set-mailbox -emailaddresses $b}
now looking for a way to remove %g.%s@newdomain.be and %m@newdomain.be as the customer wants only %g.%2s@newdomain.be
If I find it I’ll post it here, or if you know please post as well. thanks
Easiest way would be to script removal of everything for that domain then add the one you want to the address policy and apply, I have a script to remove existing addresses. I will post when back at my pc
You might want to use
$allmailboxes = get-mailbox -ResultSet unlimited
if you have more than 1000 mailboxes in your environment.
Pingback: Exchange 2010 email address policy | about:email
Pingback: Exchange 2010 email address policy « prgmr.io
Thanks for sharing, Jedi. I was able to start on this and update it for cleaning up invalid emails created (via email policies) for MailContacts and DistributionGroups as well. Let me know if any one needs it.
Hello, Jedi.
This script saved me from pulling my hair out.
Thanks a lot.
Awesome! Glad to hear it saved some hair follicles those are quite precious in the IT world!