Updating DNS records

I have been working on a couple of DNS scripts lately and (with help from this forum, ty) have just about completed them. I am working on one at the moment, however, that has some strange behavior - at least nothing I expected. The request is to feed in an array of machines, find them in DNS, and then update the IP address. I found the code below while searching best ways to do this and decided to make this the base of the script:

$oldobj = get-dnsserverresourcerecord -name $Hostname -zonename $zonename -rrtype "A"
$newobj = get-dnsserverresourcerecord -name $Hostname -zonename $zonename -rrtype "A"
$updateip = Read-host "Please enter new IP Address"
Set-dnsserverresourcerecord -newinputobject $newobj -oldinputobject $oldobj -zonename $zonename -passthru

I will need to write some logic in to search through DNS to populate the ZoneName, etc. but I figured it is a good start. In testing however, I noticed that when the A record is updated the PTR record is deleted completely. I would have expected, I guess, that it either stay the same (meaning I would have to run this same code against the PTR) or that it update to reflect the new IP. I did not expect it to be deleted altogether. Just curious if this is expected behavior, and if so is there a way to update both through the single call. Otherwise, it seems just as easy to delete both the A and PTR records, then after replication recreate them with the correct info.

Remember, even via the Windows UI’s, that a PTR record is not automatically created or updated, unless you check off those options. Well, with the exception of your DC. So, PoSH is not going to do this any differently. Thus, the additional steps required when creating a DNS record and its associated PTR record in the UI, is still a thing in automation effort.