We have several hundred users in a particular OU that we need to make some 
email changes on.  Each user has 2 email addresses,  
[email protected]<mailto:[email protected]> and 
[email protected]<mailto:[email protected]>.

I want to remove the domain1.org address from everybody in this OU and make the 
domain2.org address the primary.

I'm looking at Saint Michael's post here, which looks kinda like what I want to 
do.  
http://theessentialexchange.com/blogs/michael/archive/2009/07/07/removing-old-emailaddresses-proxyaddresses-in-exchange-2007.aspx

So if I'm following this example correctly,
                Get-mailbox -organizationalunit whateverOU |%                   
         (get all of the mailboxes from this OU)
                {
                                $a = $_.emailaddresses
                                $b = $_.emailaddresses                          
                                      (make 2 lists of the addresses)
                                Foreach ($e in $a)
                                {
                                                If ($e.tostring() -match 
"domain1.org")                (pull all addresses that match domain1.org)
                                                {
                                                                $b -= $e;       
                                                       (remove the address from 
list 2)
                                                }
                                }

                                $_ | set-mailbox -emailaddresses $b             
                        (removes the addresses from the mailbox)

And this seems to work if the address I'm removing isn't the primary address, 
which in a lot of cases it is.  Is there an easy addition to this script that 
will change the primary over to the domain2.org address first and then remove 
the domain1.org address?

Thanks Michael :)

*************************************
John C. Kelsey
DuBois Regional Medical Center
*:  814.375.3073
*  :   814.375.4005
*:   [email protected]<mailto:[email protected]>
*************************************


This email and any attached files are confidential and intended solely for the 
intended recipient(s). If you are not the named recipient you should not read, 
distribute, copy or alter this email. Any views or opinions expressed in this 
email are those of the author and do not represent those of the company. 
Warning: Although precautions have been taken to make sure no viruses are 
present in this email, the company cannot accept responsibility for any loss or 
damage that arise from the use of this email or attachments.

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe exchangelist

Reply via email to