Posts Tagged ‘DNS’

Remove DNS Host Record and PTR with PowerShell

Saturday, December 10th, 2016

You have been asked, “Please remove the host record for these 15 computers, plus their associated PTR records”.  It isn’t a difficult task, but it can be time consuming, especially if you have a large DNS database.  The bit can be annoying to do over and over again.  When I first decided to automate this task, I went looking to see who had done something similar before, and found  My code, Remove-DNSRecord.ps1,  is based on his, and extends it by searching all zones, and by creating an advanced function.  The script relies on the PowerShell DNSServer Module, which is available on Server 2008 and later.
Script Text

Export DNS Server Records with PowerShell

Sunday, March 8th, 2015

I am frequently asked to export DNS records, such as, “Give me the list of A, MX and CName records in DNSZone1 and DNSZZone2”. Server 2012 has got some nice cmdlets, but I wanted something more universal with a GUI. Export-DNSEntries.ps1 uses a combination of Out-GridView and a custom from to allow you to pick DNS zones and the records you want to export. An excerpt of the script follows — note that I have word wrap enabled in the Crayon code display window:

As you can see in line 272, I get the list of zones by querying the WMI Namespace Root\MicrosoftDNS  and Class “MicrosoftDNS_Zone”.  I use a custom form to dynamically get the record types, then query WMI for each type in each zone.

Script Text