Changing multiple resource records in DNS zone

While Microsoft gives nice documentation ( for Set-DnsServerResourceRecord and Get-DnsServerResourceRecord, there is no example on howto make changes on all records at once. Here is simple PS script for changing TTL on all A records in DNS Zone.

$TTL = [System.TimeSpan]::FromHours(12)
$ZoneName = ""
$Zone = Get-DnsServerResourceRecord -ZoneName $ZoneName -RRType "A"
foreach ($Record in $Zone) {
$New = $Old = $Record;
$New.TimeToLive = $TTL;
Set-DnsServerResourceRecord -NewInputObject $New -OldInputObject $Old -ZoneName $ZoneName -PassThru

Josip Lazić

Josip Lazić wrote 21 posts

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>