Michael Leonard
asked on
need a powershell script to modify a set of DNS records - bulk
can someone provide a script that we can run to update [modify] the IP address on a set of records.
sample would be:
record: New IP
www.domaina.com 192.168.10.1
www.domainb.com 192.168.10.1
www.domainc.com 192.168.10.1
www.domaind.com 192.168.10.1
thanks in advance.
S.
sample would be:
record: New IP
www.domaina.com 192.168.10.1
www.domainb.com 192.168.10.1
www.domainc.com 192.168.10.1
www.domaind.com 192.168.10.1
thanks in advance.
S.
Are you hoping to an additional record or remove the old one and create a new record ?
Here is an already scripted solution using dnscmd.
http://gallery.technet.microsoft.com/scriptcenter/Update-DNS-records-with-da10910d
The concept is simple you feed in values such as your dns server, zone name and an input file with the records you want to update eg. Record, IP
You can visit the link above for a detailed explanation on usage.
Here is an already scripted solution using dnscmd.
http://gallery.technet.microsoft.com/scriptcenter/Update-DNS-records-with-da10910d
The concept is simple you feed in values such as your dns server, zone name and an input file with the records you want to update eg. Record, IP
# Environment Setup
$DNSServer = "YourDNSServer"
$DNSZone = "YourZoneName"
$InputFile = "dnsrecords.csv"
# Read the input file which is formatted as name,type,address with a header row
$records = Import-CSV $InputFile
# Now we loop through the file to delete and re-create records
# DNSCMD does not have a modify option so we must use /RecordDelete first followed by a /RecordAdd
ForEach ($record in $records) {
# Capture the record contents as variables
$recordName = $record.name
$recordType = $record.type
$recordAddress = $record.address
# Build our DNSCMD DELETE command syntax
$cmdDelete = "dnscmd $DNSServer /RecordDelete $DNSZone $recordName $recordType /f"
# Build our DNSCMD ADD command syntax
$cmdAdd = "dnscmd $DNSServer /RecordAdd $DNSZone $recordName $recordType $recordAddress"
# Now we execute the command
Write-Host "Running the following command: $cmdDelete"
Invoke-Expression $cmdDelete
Write-Host "Running the following command: $cmdAdd"
Invoke-Expression $cmdAdd
}
You can visit the link above for a detailed explanation on usage.
ASKER
becraig, this appears to be specific to a single zone. in my case each line item is a different zone in the csv. thx
You can simply modify the zone input:
is the zone in the same csv as the record and IP ?
is the zone in the same csv as the record and IP ?
ASKER
but your script asks for the zone in the environmental setup at the top
Chris Dent has also written DNSShell which is now on CodePlex.
http://dnsshell.codeplex.com/
And a link with some example usage.
http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/24/weekend-scripter-use-a-free-powershell-module-to-ease-dns-administration.aspx
http://dnsshell.codeplex.com/
And a link with some example usage.
http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/24/weekend-scripter-use-a-free-powershell-module-to-ease-dns-administration.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, sorry for the delay, was out of town. that works great.
S.
S.
For server 2008 there has been a script to accomplish this using dnscmd to modify DNS records.
PS Script Download - http://gallery.technet.microsoft.com/scriptcenter/Update-DNS-records-with-da10910d
You will need to add your list of computers to the script via CSV file.
You can use the below script to get a list of computers from the DisabledComputers OU and then export them to a csv file. From there you put the file path into the PS script found at the download link...
Get-ADComputer -Filter * -SearchBase "OU=DisabledComputers,DC=d
PAQ (still open) - https://www.experts-exchange.com/questions/28275106/Require-a-PowerShell-script-to-delete-host-and-reverse-lookup-records-in-DNS-of-computers-in-a-specific-OU.html
Will.