Tuesday, January 18, 2011

PowerShell with Exchange 2003

We recently had a requirement to discover the details of exceptional mailboxes in Exchange 2003. We were aware of the Management Tools and in particular the Management Shell for Exchange 2007 which allows you to query mailbox information with a range of PowerShell commands, however we were not aware that you could use the 2007 tools to query 2003 data. In hindsight it makes sense as the data we were looking to query is held in Active Directory!

The particular scenario we were looking to find was where the UseDatabaseRetentionDefaults property is set to False. We had discovered 1 mailbox which met this criteria and the RetainDeletedItemsFor property was also set to 0, therefore once a mail item was deleted it was gone. The following command quickly output all of the mailboxes in this scenario:

[PS] C:\WINDOWS\system32>Get-Mailbox | Where {$_.UseDatabaseRetentionDefaults -eq $False} | select Name,UseDatabaseRetentionDefaults,RetainDeletedItemsFor | Export-Csv C:\UseDatabaseRetentionDefaults.csv

This web page has some other useful queries for finding other exceptional mailboxes in Exchange with both LDAP queries and the Management Tools: Find Exceptional Mailboxes in Exchange Environment.

No comments: