Hi,
As RichMatheisen-8856 pointed out above, if the DNS server is "MYDC01" and you run the script on "JumpServer01", you could specify the DNS server with the "-ComputerName" parameter.
$ServerName = "MYDC01"
$domain = "contoso.com"
import-csv C:\srv.csv | ForEach-Object {
$Computer = "$($_.HostName).$domain"
$addr = $_.IP -split "\."
$RLZ = "$($addr[2]).$($addr[1]).$($addr[0]).in-addr.arpa"
if($RLZ -notin (Get-DnsServerZone -ComputerName $ServerName).ZoneName){
Add-DnsServerPrimaryZone -Name $RLZ -ReplicationScope Forest -ComputerName $ServerName
}
Add-DnsServerResourceRecordPtr -Name "$($addr[3])" -ZoneName $RLZ -PtrDomainName $Computer -ComputerName $ServerName
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.