Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q313527

↑ Back to the top


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.

↑ Back to the top


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:
  1. Paste the following code, and then save it as Tracking.vbs:
    'TODO: Replace "COMPUTERNAME" with your Exchange server name. 
    'TODO: Replace with appropriate user name and password.
    Set Service = Locator.ConnectServer("COMPUTERNAME", "root/MicrosoftExchangeV2", "Administrator","password")
    Set Object = Service.Get("Exchange_MessageTrackingEntry")
        
    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 "COMPUTERNAME" server.    
    
    SQLQuery = "Select * from Exchange_MessageTrackingEntry"
    SQLQuery = SQLQuery & " where"
    SQLQuery = SQLQuery & " TimeLogged >=""20011017142300.000000+000"" AND"
    SQLQuery = SQLQuery & " Size < 32768 AND"
    SQLQuery = SQLQuery & " ServerName=""COMPUTERNAME.YOURDOMAINNAME.COM"""
      
    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
     
    					
  2. Make sure that you modify the items that are marked "TODO".
  3. Run the script.

↑ Back to the top


References

For more information about the properties that are supported by the Exchange_MessageTrackingEntry Class, visit the following Microsoft Web site:

↑ Back to the top


Keywords: KB313527, kbmsg, kbhowto

↑ Back to the top

Article Info
Article ID : 313527
Revision : 9
Created on : 7/13/2004
Published on : 7/13/2004
Exists online : False
Views : 408