Interrogate and change message tracking properties (Perl)
This code can be found in
Chapter 4 of Exchange Server Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# This script was originally published in the Exchange Cookbook,
# (http://www.exchangebookcook.com). Written by Paul Robichaux,
# Missy Koslosky, and Devin Ganger. Redistributed with permission
# of the publisher, O'Reilly & Associates.
# This code uses WMI to interrogate and change message tracking
# properties on the specified server.
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE qw(in);
$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
$serverList = Win32::OLE->GetObject('Exchange_Server');
foreach my $Exchange_Server (in $serverList) {
print 'Server: ' . $Exchange_Server->Name, "\n";
$isEnabled = $Exchange_Server->MessageTrackingEnabled;
if (($isEnabled)) {
print " Message tracking already enabled\n";
}
else {
$Exchange_Server->EnableMessageTracking(1);
}
print ' Current lifetime: ' . $Exchange_Server->MessageTrackingLogFileLifetime, "\n";
$Exchange_Server->{MessageTrackingLogFileLifetime} = 7;
print ' New lifetime: ' . $Exchange_Server->MessageTrackingLogFileLifetime, "\n";
print ' Current subject logging: ' . $Exchange_Server->SubjectLoggingEnabled, "\n";
$Exchange_Server->{SubjectLoggingEnabled} = 1;
print ' New subject logging: ' . $Exchange_Server->SubjectLoggingEnabled, "\n";
$Exchange_Server->Put();
}
|
This code has been viewed 834 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|