Disable dynamic updates (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.

# This code disables all dyanmic updates for a zone.
# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strZone = '<ZoneName>';
$strServer = '<ServerName>';
# ------ END CONFIGURATION ---------

$objDNS = Win32::OLE->GetObject('winMgmts:\\\\' . $strServer . '\\root\\MicrosoftDNS');
$objDNSServer = $objDNS->Get('MicrosoftDNS_Server.Name="."');
$objDNSZone = $objDNS->Get('MicrosoftDNS_Zone.ContainerName="' . $strZone . '",DnsServerName="' . $objDNSServer->Name . '",Name="' . $strZone . '"');
$objDNSZone->{AllowUpdate} = 0;
$objDNSZone->PutWScript->Echo($objDNSZone->Name . ' updated');

This code has been viewed 559 times.

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