O'Reilly logo

Exchange Server Cookbook by Devin L. Ganger, Missy Koslosky, Paul Robichaux

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.3. Controlling Message Tracking Settings

Problem

You want to configure message tracking on your servers so that you can monitor message flow.

Solution

Using a graphical user interface

  1. Launch the Exchange System Manager (Exchange System Manager.msc).

  2. In the left pane, expand the appropriate Administrative Groups container and then expand the Servers container.

  3. Right-click the target server and select Properties.

  4. Switch to the General tab of the properties dialog as shown in Figure 4-1.

  5. Enable message tracking by checking the Enable message tracking checkbox. When this setting is cleared, no message tracking information is kept.

  6. Optionally, you can allow message tracking to record message subjects by checking the Enable subject logging and display checkbox. While this may disclose sensitive information, it also makes it much easier to find exactly the message you're looking for, so we normally recommend that it be set.

  7. Check the Remove log files checkbox and specify a log file retention period. You don't have to do this, but if this checkbox is left blank, Exchange won't purge these files on its own, and they will eventually use all available disk space.

  8. Optionally, change the message tracking log file location with the Change button. Exchange automatically shares the message tracking log directory so that one server can be searched from others; bear this in mind when choosing a location.

The General tab of the server properties dialog gives you control over message tracking options

Figure 4-1. The General tab of the server properties dialog gives you control over message tracking options

Using VBScript

' This code uses WMI to interrogate and change message tracking 
' properties on the specified server.
' ------ SCRIPT CONFIGURATION ------
strComputerName = "<ServerName>"  ' e.g., batman
' ------ END CONFIGURATION ---------
  strE2K3WMIQuery = "winmgmts://" & strComputerName &_
    "/root/MicrosoftExchangeV2"
  
  ' Find each Exchange 2003 server and display its message tracking status.
  ' Then, turn on message tracking and subject display and set the 
  ' log retention period to 7 days. Real code should include error checking here
  Set serverList = GetObject(strE2K3WMIQuery).InstancesOf("Exchange_Server")
  
  For each Exchange_Server in serverList
      WScript.Echo "Server:        " & Exchange_Server.Name
      isEnabled = Exchange_Server.MessageTrackingEnabled
      If (isEnabled) Then
        WScript.echo "      Message tracking already enabled"
        Else
          Exchange_Server.EnableMessageTracking(True)
          
        End if
      WScript.Echo  "      Current lifetime: " & 
         Exchange_Server.MessageTrackingLogFileLifetime
      Exchange_Server.MessageTrackingLogFileLifetime = 7
      WScript.Echo  "      New lifetime:     " & 
        Exchange_Server.MessageTrackingLogFileLifetime
      WScript.Echo  "      Current subject logging:     " & 
        Exchange_Server. SubjectLoggingEnabled
      Exchange_Server.SubjectLoggingEnabled = True
      WScript.Echo  "      New subject logging:         " & 
       Exchange_Server. SubjectLoggingEnabled
      Exchange_Server.Put_     
  Next

Discussion

Exchange 2000 and 2003 offer a fairly flexible message tracking system that lets you search for individual messages by sender, recipient, date, and time. This is invaluable when trying to find out why a particular user's messages didn't go where they were supposed to. For message tracking to be effective, it has to be enabled on all servers in the organization; if not, you won't be able to track a message's complete path through your organization. For example, if Alice (on a server in routing group A) sends a message to Zeke (whose mailbox server is in routing group Z), the message may (and probably will) transit other servers; if tracking is disabled on any of those intermediate servers, the trail will stop dead. As an alternative to setting message tracking properties on every individual server, you can create an Exchange system policy that applies the tracking settings you want to use; see Recipe 4.5.

Using VBScript

Exchange Server 2003 includes message tracking properties in the Exchange_Server object, but Exchange 2000 doesn't, so there's no good way to programmatically control message tracking settings there. As part of the Exchange Server 2003 WMI provider, you can optionally specify a location of the tracking logs when you call EnableMessageTracking() , but you have to write your own code to move existing log files and set up the folder structure yourself if you're moving the logs to a nonstandard location.

See Also

Recipe 4.5 for using Exchange system policies; MS KB 823864 (Improved Message Tracking Features in Exchange Server 2003)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required