Saturday, August 11, 2007

Documenting the Exchange Server

Documenting an exchange server is very easy. Below is example code on how to get the basic information from your exchange server.

dim strComputer, objWMIService, colItems


strComputer = "zeus"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & _
"\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery("Select * from Exchange_Server")

For Each objItem in colItems
Wscript.Echo "Administrative group: " & _
objItem.AdministrativeGroup
Wscript.Echo "Administrative note: " & objItem.AdministrativeNote
Wscript.Echo "Creation time: " & objItem.CreationTime
Wscript.Echo "Distinguished name: " & objItem.DN
Wscript.Echo "Exchange version: " & objItem.ExchangeVersion
Wscript.Echo "Fully-qualified domain name: " & objItem.FQDN
Wscript.Echo "GUID: " & objItem.GUID
Wscript.Echo "Is front-end server: " & objItem.IsFrontEndServer
Wscript.Echo "Last modification time: " & _
objItem.LastModificationTime
Wscript.Echo "Message tracking enabled: " & _
objItem.MessageTrackingEnabled
Wscript.Echo "Message tracking log file lifetime: " & _
objItem.MessageTrackingLogFileLifetime
Wscript.Echo "Message tracking log file path: " & _
objItem.MessageTrackingLogFilePath
Wscript.Echo "Monitoring enabled: " & objItem.MonitoringEnabled
Wscript.Echo "MTA data path: " & objItem.MTADataPath
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Routing group: " & objItem.RoutingGroup
Wscript.Echo "Subject logging enabled: " & _
objItem.SubjectLoggingEnabled
Wscript.Echo "Type: " & objItem.Type
Wscript.Echo
Next

Copy the code into notepad, change the strComputer = "Zeus" to the name of your exchange server. Save the file as c:\test.vbs (or to whatever directory and name you wish). Now you are ready to run the script. Open up a dos prompt and navigate to the directory where you saved the file. Type the following into the command prompt: cscript test.vbs

Below is an example of the output of that script.
Administrative group: first administrative group
Administrative note:
Creation time: 20060312234931.000000+000
Distinguished name: CN=ZEUS,CN=Servers,CN=first administrative group,CN=Administ
rative Groups,CN=OLYMPUS,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=o
lympus,DC=local
Exchange version: Version 6.5 (Build 7638.2: Service Pack 2)
Fully-qualified domain name: zeus.olympus.local
GUID: {AC977A9B-A731-4C52-959B-00EE8BFC281B}
Is front-end server: False
Last modification time: 20060409062441.000000+000
Message tracking enabled: True
Message tracking log file lifetime: 7
Message tracking log file path: C:\Program Files\Exchsrvr\ZEUS.log
Monitoring enabled: True
MTA data path: C:\Program Files\Exchsrvr\mtadata
Name: ZEUS
Routing group: first routing group
Subject logging enabled: False
Type: 0

As you can see, this will give you some basic information about the exchange server. On the next post, i will get into displaying the mailbox information for each user.

No comments: