Create a mail forwarder (Perl)

This code can be found in Chapter 12 of Windows Server 2003 Security 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.

# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strDNSServer = '<DNSservername>';
$strContainer = '<containername>';
$strOwner = '<ownername>';
$intRecordClass = 1;
$intTTL = 600;
$strMailForwarder = '<mailforwardername>';
# ------ END CONFIGURATION ---------

$strComputer = '.';
$objWMIService = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\MicrosoftDNS');
$objItem = $objWMIService->Get('MicrosoftDNS_MFType');
$errResult = $objItem->CreateInstanceFromPropertyData($strDNSServer, $strContainer, $strOwner, $intRecordClass, $intTTL, $strMailForwarder);

This code has been viewed 819 times.

New from the creators of TechTasks.com: StatSheet.com