none
Change DNS forwarders on multiple DC / DNS servers RRS feed

  • Question

  • I have been asked to update 69 Domain Controllers / DNS servers with new forwarder IPs. I would like to accomplish this via Powershell and a text file listing the hostnames rather than logging on and updating each one individually. I have compiled a list of the servers, but the script to modify all the DCs is more problematic. There is one on Technet available for this very purpose (url here), but it is falling over whenever I run it. Unfortunately the glut of errors I receive do not mean a great deal to me. I hope someone can help me fix this.

    Error as below:

    PS C:\Windows\system32> C:\Temp\Update DNS Fowarder.ps1
    gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At C:\Temp\Update DNS Fowarder.ps1:6 char:17
    + $objDNSServer = gwmi -Namespace "root\testlab" `
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
        + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWm
       iObjectCommand
     
    The property 'Forwarders' cannot be found on this object. Verify that the property
    exists and can be set.
    At C:\Temp\Update DNS Fowarder.ps1:8 char:1
    + $objDNSServer.Forwarders = $arrFowarders
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    You cannot call a method on a null-valued expression.
    At C:\Temp\Update DNS Fowarder.ps1:9 char:1
    + $output = $objDNSServer.put()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
     
    Configuration Complete. List of domain controllers with accounts in the domain:
    Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument
    is null or empty. Provide an argument that is not null or empty, and then try the
    command again.
    At C:\Temp\Update DNS Fowarder.ps1:7 char:42
    + -Class MicrosoftDNS_server -ComputerName $computer
    +                                          ~~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindingVali
       dationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.
       Commands.GetWmiObjectCommand
     
    The property 'Forwarders' cannot be found on this object. Verify that the property
    exists and can be set.
    At C:\Temp\Update DNS Fowarder.ps1:8 char:1
    + $objDNSServer.Forwarders = $arrFowarders
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    You cannot call a method on a null-valued expression.
    At C:\Temp\Update DNS Fowarder.ps1:9 char:1
    + $output = $objDNSServer.put()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
     
    Configuration Complete.
    gwmi : Invalid namespace "root\testlab"
    At C:\Temp\Update DNS Fowarder.ps1:6 char:17
    + $objDNSServer = gwmi -Namespace "root\testlab" `
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-WmiObject], ManagementExcept
       ion
        + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Command
       s.GetWmiObjectCommand
     
    The property 'Forwarders' cannot be found on this object. Verify that the property
    exists and can be set.
    At C:\Temp\Update DNS Fowarder.ps1:8 char:1
    + $objDNSServer.Forwarders = $arrFowarders
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    You cannot call a method on a null-valued expression.
    At C:\Temp\Update DNS Fowarder.ps1:9 char:1
    + $output = $objDNSServer.put()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
     
    Configuration Complete. TESTLAB-DC01
    gwmi : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At C:\Temp\Update DNS Fowarder.ps1:6 char:17
    + $objDNSServer = gwmi -Namespace "root\testlab" `
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
        + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWm
       iObjectCommand
     
    The property 'Forwarders' cannot be found on this object. Verify that the property
    exists and can be set.
    At C:\Temp\Update DNS Fowarder.ps1:8 char:1
    + $objDNSServer.Forwarders = $arrFowarders
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    You cannot call a method on a null-valued expression.
    At C:\Temp\Update DNS Fowarder.ps1:9 char:1
    + $output = $objDNSServer.put()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
     
    Configuration Complete. The command completed successfully.
    Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument
    is null or empty. Provide an argument that is not null or empty, and then try the
    command again.
    At C:\Temp\Update DNS Fowarder.ps1:7 char:42
    + -Class MicrosoftDNS_server -ComputerName $computer
    +                                          ~~~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindingVali
       dationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.
       Commands.GetWmiObjectCommand
     
    The property 'Forwarders' cannot be found on this object. Verify that the property
    exists and can be set.
    At C:\Temp\Update DNS Fowarder.ps1:8 char:1
    + $objDNSServer.Forwarders = $arrFowarders
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound
     
    You cannot call a method on a null-valued expression.
    At C:\Temp\Update DNS Fowarder.ps1:9 char:1
    + $output = $objDNSServer.put()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
     
    Configuration Complete.

    Wednesday, September 21, 2016 9:34 AM

Answers

  • Apparently the script is unable to retrieve data from remote dns server. Make sure that RPC connections are allowed through network and local firewalls, and, remote registry and remote management services are running on DNS servers.

    If DNS servers are AD-integrated, then check replication scope in forwarder configuration: AD integrated servers can replicate forwarders to all DNS servers in forest or domain, so there will be no need to change it on each server.

    You can also use DNS Server cmdlets in PowerShell instead of WMI


    Gleb.

    Wednesday, September 21, 2016 10:15 AM
  • In the end I just used

    Set-DnsServerForwarder -Computername <hostname> -IPAddress <x.x.x.x> -PassThru

    Although I created a file dump with all the  DNS servers, I did not have time to work out how to feed it to the command to automate it completely (testing would have had to be totally bulletproof).
    Wednesday, September 28, 2016 9:00 AM

All replies

  • Apparently the script is unable to retrieve data from remote dns server. Make sure that RPC connections are allowed through network and local firewalls, and, remote registry and remote management services are running on DNS servers.

    If DNS servers are AD-integrated, then check replication scope in forwarder configuration: AD integrated servers can replicate forwarders to all DNS servers in forest or domain, so there will be no need to change it on each server.

    You can also use DNS Server cmdlets in PowerShell instead of WMI


    Gleb.

    Wednesday, September 21, 2016 10:15 AM
  • In the end I just used

    Set-DnsServerForwarder -Computername <hostname> -IPAddress <x.x.x.x> -PassThru

    Although I created a file dump with all the  DNS servers, I did not have time to work out how to feed it to the command to automate it completely (testing would have had to be totally bulletproof).
    Wednesday, September 28, 2016 9:00 AM
  • Hi,

    Thank you for sharing to us.


    Best Regards,
    Cartman
    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, September 28, 2016 9:05 AM