DNS Lookup

This topic contains 2 replies, has 2 voices, and was last updated by  Dan Potter 1 year, 9 months ago.

  • Author
  • #51955

    Mike Catalano

    Everything I've read online about this topic always contains how to look up multiple IP's from a single name server. I'm looking to do the opposite to test conditional forwarders on multiple domain controllers. The script I have tests the URL against an array of domain controllers, and it works. I'm trying to figure out how I can output which DC failed to resolve when it errors. Any suggestions?

    $URL = "URL"
    $NameServers = @("Domain Controller 1", "Domain Controller 2", "Domain Controller 3", "Domain Controller 4")
    foreach ($NameServer in $NameServers){
    Resolve-DnsName -Name $URL -Server $NameServer
  • #51961

    Dan Potter

    Architect tip: make your life easier and make all dc's gc's and all gc's dns servers.

    $dcs = (Get-ADDomainController -Filter * | select -first 3).name
    $url = 'www.powershell.org'

    foreach ($dc in $dcs){if(!(Resolve-DnsName $url -Server $dc)){"$dc failed to resolve $url"}}

    Fyi.. $NameServers = "Domain Controller 1", "Domain Controller 2", "Domain Controller 3", "Domain Controller 4" is just as good as @()

  • #51963

    Dan Potter

    throw an error action in there.

    Resolve-DnsName $url -Server $dc -ea silentlycontinue

You must be logged in to reply to this topic.