The Multifunctioning DBA

Aug 29 2010   10:00AM GMT

Exchange Email Changes (Mailboxes)

Colin Smith Colin Smith Profile: Colin Smith

So lets dive into some of the code in order to get this thing done. This post will be in multiple parts since I actually am still not done writing the code. I have done the majority of it at this time and can start sharing thought. So one thing that you need to know is that I am working on this for a child domain in the forrest. Today I am going to talk about how to get the mailbox information out of exchange so we can start comparing and testing. I certainly do not want to get mailbox information for the entire Forrest of mailboxes. That would be way to many and I have no need to gather all that information. In order to get the information on the mailboxes that I am concerned with I did the following.

$mailboxes = get-mailbox -OrganizationalUnit -ResultSize unlimited |where{$_.recipienttypedetails -eq “UserMailBox”

with my actual OU information of course. Now that will go get all the mailbox information from that OU and store it all in $mailboxes. The | where works so that I am ot gathering any roommailboxes so things like calendars and public folders are not going to be gathered into this list.  Next I figured that I wanted to output a list of all smtp address that are used to a file so I can compare addresses that I am creating to addresses that are already being used. For that I did the following loop.

$comparefile = c:\compare.txt

foreach($mailbox in $mailboxes)\


$smtpaddresses = $mailbox.emailaddresses | where {$_.prefixstring -eq “smtp”}

foreach($smtpaddress in $smtpaddresses)


$addstring = $smtpaddress.addressstring

$addstring >>  $comparefile



What I did is I go thru each mailbox one by one and I pull out all of the smtp type addresses, My company also has Notes type addresses and I am not concerned with those. Once I have all of the smtp addresses for that mailbox now I need to go thru all of those for each user one at a time and get the smtp string field and then output that to $comparefile.

So that will give me a txt file with every smtp address that my OU is using.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: