title: Update DNS records with powershell
body: <p>i would like to write a powershell script that will update the name of a list of DNS A records.</p>
  <p>However , i also need to update the PTR records that correspond to the DNS records.
  As far as i read there is no parameter that will do this for me automatically and i decided to write a separate script that will handle the Ptr records.</p>
  <p>I am not sure what is the correct approach to update the pointer record PtrDomainName(see code below).
  I managed to find info about the approach to change the IP and the TTL (both in my code) but the name is missing.</p>
  <pre><code>$records = Get-Content .\ptr_records.txt
  
  foreach ($record in $records){
      #modify the records
      $OldObj = Get-DnsServerResourceRecord -ZoneName 10.in-addr.arpa -RRType Ptr | Where-Object {$_.RecordData.PtrDomainName -like $record }
      $NewObj = $OldObj.Clone()
      ###below line modifies time to live
      $NewObj.TimeToLive = [System.TimeSpan]::FromHours(2) 
      ###below line modifies ip
      $NewObj.RecordData.IPv4Address = [ipaddress]'8.8.8.8'
      ###how do i modify the record data?????
      $NewObj.RecordData= ??? 
  Set-DnsServerResourceRecord -NewInputObject $NewObj -OldInputObject $OldObj -ZoneName &quot;10.in-addr.arpa&quot; -PassThru
      
  }
  
  </code></pre>
  <p>here is also some powershell output:</p>
  <p>in the example below dnsrecord1 will be changed to dnsrecord2</p>
  <pre><code>
  
  PS C:\Users\da.v.kolev&gt; $test = Get-DnsServerResourceRecord -ZoneName 10.in-addr.arpa -RRType Ptr | Where-Object {$_.RecordData.PtrDomainName -like 'dnsrecord1.contoso.com.' }
  PS C:\Users\da.v.kolev&gt; $test
  
  HostName                  RecordType Type       Timestamp            TimeToLive      RecordData
  --------                  ---------- ----       ---------            ----------      ----------
  1.33.22                   PTR        12         0                    01:00:00     dnsrecord1.contoso.com.
  
  
  PS C:\Users\da.v.kolev&gt; $test.RecordData
  
  PtrDomainName                          PSComputerName
  -------------                          --------------
  dnsrecord1.contoso.com.
  
  
  PS C:\Users\da.v.kolev&gt; $test.RecordData.PtrDomainName
  dnsrecord1.contoso.com.
  PS C:\Users\da.v.kolev&gt;
  </code></pre>