Home

Black Mountain

My Experiment on the Internet

PowerShell - list Exchange 2003 mailbox information

We have been exporting some mailbox information manually and I was sort of tired of doing it that way. I thought I'd try to make it work with PowerShell to automate it and add some consistency. It took some experimentation and here it is.

It saves to a file, ServerName-Date.csv in the directory it's run from. It has Display Name, Storage Group Name, Store Name, Mailbox size (in kb like ESM) and Date Discovered Absent in DS (which is short for when the Active Directory account the mailbox was associated was deleted).

#        Name:  list-exchange-mailbox.ps1
#      Author:  Steven Peck   - www.blkmtn.org
#        Date:  06/15/2007
# Description:  Exchange 2003 output to file
#        Display Name, Store, Storage group, MB Size, and Date Absent in DS
#

# Get date for file name
$day = Get-Date -UFormat "%Y%m%d"

# Gets data through WMI from specified Exchange mailbox servers
$computers = "server001","server002"
foreach ($computer in $computers) {
  Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $computer | sort-object -desc MailboxDisplayName | select-object MailboxDisplayName,StorageGroupName,StoreName,Size,DateDiscoveredAbsentInDS | Export-Csv -Path $computer-$day.csv
}

I am probably going to make one for just DateDiscoveredAbsentInDS as searching through multiple mail stores to find a mailbox to re-associate it when the account was deleted is a pain. One specific item to add will be an exclusion for "Recovery Storage Groups' as those are all disjointed accounts by their very nature. Using where on a sort should make it easy (I hope).

Using just the get-wmiobject portion of the script in a PowerShell console window, you can see a number of other objects your could modify the script to display on.

Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer MAILBOX_SERVERNAME

For those new to PowerShell as I am, check out the PowerShell Team blog and this new PowerShell podcast series looks promising (I haven't listened to it yet, I noticed it while getting the other link in this post).

I am submitting this to the MS Community Script Center as my first ever submission. We'll see if they accept it.

Great Script

I am trying to find a way to display the Users OU info. I can't find an easy way of doing this. Do you know?

Very useful... FYI, I found

Very useful...

FYI, I found that you can add a filter to the script to only retrieve mailboxes over 2gb in size. (So you can notify your large mailbox users that their offline folders is likely corrupt and useless.) Here is the changed portion of code with the filter added.

Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $computer <strong>-Filter "size>=2097152"</strong> | ...

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <blockquote> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Sometimes I get asked, so here it is ... My Amazon.com Wish List

Thought I'd see what this Technorati stuff does.

Login with your OpenID to leave comments
contents copyright Steven Peck - powered by drupal logo