Microsoft KB Archive/313527

= How To Track Messages on Exchange Server by Using Windows Management Instrumentation =

Article ID: 313527

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Exchange 2000 Server Service Pack 2

-



This article was previously published under Q313527



SUMMARY
This sample script shows how to connect to a remote Exchange server and track the events that have occurred to messages.

NOTE: Message Tracking must be enabled on the Exchange server.



MORE INFORMATION
Use the Microsoft Windows Management Instrumentation (WMI) provider ExchangeMessageTrackingProvider to track the events. The namespace that you look for is \\COMPUTERNAME\ROOT\MicrosoftExchangeV2:Exchange_MessageTrackingEntry.

Sample Code
To run the sample script, follow these steps:   Paste the following code, and then save it as Tracking.vbs: 'TODO: Replace &quot;COMPUTERNAME&quot; with your Exchange server name. 'TODO: Replace with appropriate user name and password. Set Service = Locator.ConnectServer(&quot;COMPUTERNAME&quot;, &quot;root/MicrosoftExchangeV2&quot;, &quot;Administrator&quot;,&quot;password&quot;) Set Object = Service.Get(&quot;Exchange_MessageTrackingEntry&quot;) wscript.echo Object.Path_.DisplayName ' Build a query that looks for messages that have been ' logged after 10/17/2001 and size < 32768 on the &quot;COMPUTERNAME&quot; server.

SQLQuery = &quot;Select * from Exchange_MessageTrackingEntry&quot; SQLQuery = SQLQuery & &quot; where&quot; SQLQuery = SQLQuery & &quot; TimeLogged >=&quot;&quot;20011017142300.000000+000&quot;&quot; AND&quot; SQLQuery = SQLQuery & &quot; Size < 32768 AND&quot; SQLQuery = SQLQuery & &quot; ServerName=&quot;&quot;COMPUTERNAME.YOURDOMAINNAME.COM&quot;&quot;&quot; Set messages = Service.ExecQuery(SQLQuery) wscript.echo messages.Count

' Print the subject of the message and the EntryType property, ' which would tell you the status of the message.

For Each message In messages wscript.echo message.subject wscript.echo message.EntryType Next  Make sure that you modify the items that are marked &quot;TODO&quot;. Run the script.

