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 "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
- Make sure that you modify the items that are marked "TODO".
- Run the script.