One Step Further: Configuring Message Tracking


In this exercise, we will examine the use of Windows PowerShell to configure message tracking on an Exchange 2007 server.

  1. Open Notepad or another Windows PowerShell script editor.

  2. Declare a variable called $dteMaxAge and use the timespan accelerator to convert a string type into a timespan data type. Set the timespan to be equal to 30 days, 0 hours, 0 minutes, and 0 seconds. The line of code that does this is shown here:

     $dteMaxAge = [timespan]"30.00:00:00"

  3. On the next line, create a variable called $intSize and use it to hold the value 50MB. The Set-MailboxServer cmdlet expects a value with both the number and suffix to indicate whether the number is megabytes or kilobytes or some other size of number. To do this, use the following code:

     $intSize = 50MB

  4. On the next line, use the variable $strLogPath to hold the string representing the path for storing the message tracking logs. This needs to be a path that is local to the actual Exchange server. To do this, we used the following code:

     $strLogPath = "c:\x2kLogs"

  5. Use the variable $aryServer to hold a collection of Exchange mailbox servers obtained by using the Get-MailboxServer cmdlet. This line of code is shown here:

     $aryServer = Get-MailboxServer

  6. Use the ForEach statement to walk through the collection of Exchange servers held in the $aryServer variable. Use the variable $strServer as the counter-variable while you go through the array. This line is code is shown here:

     foreach ($strServer in $aryServer)

  7. Open and close the code block by typing an opening curly bracket and a closing curly bracket, as shown here:

     { }

  8. Use the variable $strServer to hold the Identity property that is returned by querying the Identity property from the object contained in the $strServer variable. This line of code is shown here:

     $strServer = $strServer.identity

  9. On the next line, use the Set-MailboxServer cmdlet and supply the value for the identity argument with the string contained in the $strServer variable. Use the grave accent character (`) to continue the command to the next line. The code that does this is shown here:

     Set-MailboxServer -identity $strServer

  10. On the next line, use the MessageTrackingLogEnabled argument to turn on message tracking. To do this, use the value $true as the value for the MessageTrackingLogEnabled argument. The line of code that does this is shown here. Make sure you include the grave accent character at the end of the line to continue the command to the next line.

     -MessageTrackingLogEnabled $true

  11. On the next line, use the MessageTrackingLogMaxAge argument to set the maximum age of the message tracking logs. Use the timespan data type to supply the value to the MessageTrackingLogMaxAge argument. To do this, use the value stored in the $dteMaxAge variable. This line of code is shown here. At the end of the line, use the grave accent character to continue the code to the next line.

     -MessageTrackingLogMaxAge $dteMaxAge

  12. Now we need to configure the size of the logging directory. To do this, use the MessageTrackingLogMaxDirectorySize argument of the Set-MailboxServer cmdlet. When you specify a value for the directory size, you can tell it you want MB for megabytes, GB for gigabytes, KB for kilobytes, and even B for bytes and TB for terabytes. To make it easy to change later, we stored the max directory size value in a variable called $intSize. The code that sets this argument is shown here:

     -MessageTrackingLogMaxDirectorySize $intSize

  13. The last parameter we need to configure for message tracking is the path for log storage. This needs to be a local path on the Exchange server. We used the following line of code to configure the MessageTrackingLogPath argument:

     -MessageTrackingLogPath $strLogPath

  14. Save your script as yournameimage from book EnableMessageTracking.ps1. Run your script. If it does not produce the desired results, then compare it with image from book EnableMessageTracking.ps1.

  15. This concludes this one step further exercise.




Microsoft Press - Microsoft Windows PowerShell Step by Step
MicrosoftВ® Windows PowerShell(TM) Step By Step (Step By Step (Microsoft))
ISBN: 0735623953
EAN: 2147483647
Year: 2007
Pages: 128
Authors: Ed Wilson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net