Sorry for the reply and did not get a chance
Here is error I got when I ran the script. (I did replace mydomain.local.com with my zone name)
Get-DnsServerResourceRecord : Failed to get the zone information for mydomain.local.com on server server1.
At line:2 char:12
- $OldObj = Get-DnsServerResourceRecord -Name $server -ZoneName "mydomain ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (mydomain.local.com:root/Microsoft/...rResourceRecord) [Get-DnsServerResourceRec
ord], CimException
- FullyQualifiedErrorId : WIN32 1722,Get-DnsServerResourceRecord
You cannot call a method on a null-valued expression.
At line:3 char:2
- $NewObj = $OldObj.Clone()
- ~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
The property 'TimeToLive' cannot be found on this object. Verify that the property exists and can be set.
At line:4 char:2
- $NewObj.TimeToLive = [System.TimeSpan]::FromHours(0)
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : PropertyNotFound
Set-DnsServerResourceRecord : Cannot validate argument on parameter 'NewInputObject'. The argument is null or empty.
Provide an argument that is not null or empty, and then try the command again.
At line:5 char:46
- Set-DnsServerResourceRecord -NewInputObject $NewObj -OldInputObject ...
- ~~~~~~~
- CategoryInfo : InvalidData: (:) [Set-DnsServerResourceRecord], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationError,Set-DnsServerResourceRecord