We all know that PowerShell and Exchange 2007 were made for one another. However, that doesn’t mean you can’t use PowerShell to manage Exchange 2003 servers. I’m not saying you can get all the functionality that you do with Exchange 2007, but you’re not totally left out either. Exchange 2003 added many WMI classes and the Get-WMIObject cmdlet is perfect for getting information from Exchange 2003. In fact, because of pipelining, it is even easier to get information properly formatted than it is using VBScript.
The first thing to note is that instead of connecting to the default root\cimv2 namespace, you need to connect to root\MicrosoftExchangeV2. Here’s a simple PowerShell expression you can run:
Get-Wmiobject -query “Select * from Exchange_Server” –namespace root\MicrosoftExchangeV2 -computer TANK
This code was executed from a another server in the domain connecting to the Exchange 2003 server, TANK. This is the output I got back:
__GENUS : 2
__CLASS : Exchange_Server
__SUPERCLASS : CIM_LogicalElement
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Exchange_Server.FQDN=“TANK.matrix.local”
__PROPERTY_COUNT : 22
__DERIVATION : {CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER : TANK
__NAMESPACE : root\MicrosoftExchangeV2
__PATH : \TANK\root\MicrosoftExchangeV2:Exchange_Server.FQDN=”TANK.matrix. AdministrativeGroup : First Administrative Group
AdministrativeNote :
Caption :
CreationTime : 20041201202912.000000+000
Description :
DN : CN=TANK,CN=Servers,CN=First Administrative Group,CN=Administrative =Microsoft Exchange,CN=Services,CN=Configuration,DC=matrix,DC=local ExchangeVersion : Version 6.5 (Build 7638.2: Service Pack 2)
FQDN : TANK.matrix.local
GUID : {9B9A3518-49AF-463D-9FAD-635CD8F60F10}
InstallDate :
IsFrontEndServer : False
LastModificationTime : 20051101214324.000000+000
MessageTrackingEnabled : False
MessageTrackingLogFileLifetime : 0
MessageTrackingLogFilePath : C:\Program Files\Exchsrvr\TANK.log MonitoringEnabled : True
MTADataPath : C:\Program Files\Exchsrvr\mtadata
Name : TANK
RoutingGroup : First Routing Group
Status :
SubjectLoggingEnabled : True
Type : 1
Pretty handy don’t you think? But I have to say I like using PowerShell for this sort of thing even better than VBScript. With PowerShell I can take the results of my WMI query, sort, select and format all in a single expression. Ever wonder who the top 10 mailbox “offenders” are on your Exchange server? Try this:
Get-Wmiobject –namespace root\MicrosoftExchangeV2 –class Exchange_Mailbox -computer TANK ` | sort -desc size | select `
StorageGroupName,StoreName,MailboxDisplayName,Size,TotalItems -first 10
And this is the report I get:
StorageGroupName StoreName MailboxDisplayName Size TotalItems
---------------- --------- ------------------ ---- ----------
Second Storage Group Sales Mailboxes Barb Zpuutwoko 2691 77
Second Storage Group Sales Mailboxes Barb Zemnyzdpg 2691 77
Second Storage Group Sales Mailboxes Barb Yzdpmbctwf 2691 77
Second Storage Group Sales Mailboxes Barb Ksuvrel 2690 77
Second Storage Group Sales Mailboxes Barb Pks 2687 77
First Storage Group Mailbox Store (TANK) Administrator 2595 31
First Storage Group Mailbox Store (TANK) Charlie Brown 1667 94
First Storage Group Beta Mail Ellen Rkobymnenr 1081 81
First Storage Group Beta Mail Ellen Sdoadbhjrb 1081 81
First Storage Group Beta Mail Ellen Vlgplgntk 1080 81
I’ll explore some other things we can do with PowerShell and Exchange 2003 in future posts.
Thanks for this post.
It was very helpful