document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Code Snippet from aperturescience.su
  2.  
  3. $hosts= <array of the hostnames of DNS servers to allow transfers from?
  4.  
  5. $masterdns = $hosts[0]
  6.  
  7. $newdnshost = read-host "Enter new host name (FQDN)"
  8.  
  9. $enumzones = get-WMIObject -Computer $masterdns -Namespace "root\\MicrosoftDNS" `
  10.     -Class "MicrosoftDNS_Zone"
  11.  
  12. foreach ($zone in $enumzones)
  13. {
  14.     if ($zone.zonetype -eq 1)
  15.     {
  16.         write-host ""
  17.         $name = $zone.name
  18.        
  19.         foreach ($dnsserver in $hosts) {
  20.             #Allow zone transfers only to dns servers listed using ns resource records
  21.             dnscmd $dnsserver /zoneresetsecondaries $name /SecureNs /Notify
  22.             #write-host $dnsserver $name
  23.             Write-host "Enabled SecureNS on "$dnsserver
  24.         }
  25.        
  26.         #add the host to ns list
  27.         dnscmd $masterdns /RecordAdd $name "@" NS $newdnshost
  28.         #Write-host $masterdns $name $newdnshost
  29.         Write-Host "NS Record for "$newdnshost " added to "$name
  30.     }
  31.  
  32. }
  33.  
  34. # Code Snippet from aperturescience.su
');