none
View Secondary zone under primary zones RRS feed

  • Question

  • Query / Get a list of Secondary Zones under Primary Zones in DNS, I do not want to create/Add Secondary Zones.  Example code below directly pointing to a DNS server and then a primary zone, but not Secondary Zones will be listed.  Does anyone know another method or cmdlet to use to get a listing of the Secondary Zones under a Domain without hardcoding it. Cheers,

    Example Code:

    $DNSServer = "domain.test.local"
    $All = @()
    $Zones = @(Get-DnsServerZone -ComputerName $DNSServer -Name test.net)
    ForEach ($Zone in $Zones) 
    {	
      $Results = $Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer	
      $All += $Results
    }
    $All | Sort-Object HostName
    Wednesday, February 20, 2019 8:48 PM

All replies

  • Query / Get a list of Secondary Zones under Primary Zones in DNS, I do not want to create/Add Secondary Zones.  Example code below directly pointing to a DNS server and then a primary zone, but not Secondary Zones will be listed.  Does anyone know another method or cmdlet to use to get a listing of the Secondary Zones under a Domain without hardcoding it. Cheers,

    Example Code:

    $DNSServer = "domain.test.local"
    $All = @()
    $Zones = @(Get-DnsServerZone -ComputerName $DNSServer -Name test.net)
    ForEach ($Zone in $Zones) 
    {	
      $Results = $Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer	
      $All += $Results
    }
    $All | Sort-Object HostName


    • Edited by Mighty Koontz Wednesday, February 20, 2019 7:25 PM
    • Merged by jrv Wednesday, February 20, 2019 8:59 PM Moved to DNS
    Wednesday, February 20, 2019 3:15 PM
  • The Get-ADDomain cmdlet has a ChildDomains property.

    https://docs.microsoft.com/en-us/powershell/module/activedirectory/get-addomain?view=winserver2012-ps

    Edit: Another method uses the Get-ADForest cmdlet, but this retrieves all domains in the forest.

    $Domains = (Get-ADForest).Domains
    ForEach ($Domain In $Domains)
    {
        "Domain: $Domain"
    }
    


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)


    Wednesday, February 20, 2019 4:25 PM
  • Why is it always necessary to crosspost the same question in different forums before you even get an answer in one of them? And you dont even reply. :-/

    https://powershell.org/forums/topic/cmdlet-code-to-show-subdomains-under-domains-in-dns/#post-140646


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Wednesday, February 20, 2019 6:01 PM
  • I just responded to that post, appreciate the responses.

    Why do i post in two spots, different people in different forums.  Can't assume the people that will respond will exist in both forums.  

    I will take a look into those cmdlets to see if I can pull that information in regards to the primary domains, to get the subdomains. Thanks

    Wednesday, February 20, 2019 6:32 PM
  • Updated the question and text to be more clear I want to get the zone name information and not initially about domains.

    Example:

    DNS
            (DNS Server)
                     Forward Lookup Zones
                                Zone Name (Domain Name)
                                       Zone Name (Domain Name) << - want to grab this name, not the records.

    Wednesday, February 20, 2019 7:28 PM
  • You will get the same thing by asking AD for the subdomains and extracting the name from the domain.

    Get-ADDomain | select Name,dnsroot

    You can also use "Get-DNSServerZone" an extract the hierarchy.

    You would do better posting this in the DNS forum.


    \_(ツ)_/

    Wednesday, February 20, 2019 7:52 PM
  • Is there a way i can move the question/data to the DNS forum or i just got to start a new one?

    Get-DNSServerZone will get me the primary zone names, Get-ADDomain will not.  

    Wednesday, February 20, 2019 8:16 PM
  • Created under DNS forums..

    https://social.technet.microsoft.com/Forums/windows/en-US/5fa44675-beec-468a-8a53-9e83648c6024/view-secondary-zone-under-primary-zones?forum=winserveripamdhcpdns

    • Marked as answer by Mighty Koontz Wednesday, February 20, 2019 8:49 PM
    Wednesday, February 20, 2019 8:49 PM
  • A little patience an I would have moved it.


    \_(ツ)_/

    Wednesday, February 20, 2019 8:57 PM
  • Original thread is now merged into your new thread.'

    Good luck.

    You can also just get all zones and use the dnsname to fin the list of subzones.  All childzones are in the parent zone.

    parent -> domain.com
    child1 --> child1.domain.com
    child2 --> child2.domain.com.

    Just get the strings and parse.


    \_(ツ)_/

    Wednesday, February 20, 2019 9:05 PM
  • Thank you for moving the threat over.

    I can get all the zone names under the DNS server/forwarder, the child objects don't show up.  Just the primary ones.  Thought I could use this cmdlet Get-DnsServerZoneDelegation  to return the child objects under the primary zone, but return blank results.

    Wednesday, February 20, 2019 11:08 PM
  • Hi,

    Thanks for posting in the forum.

    We've found a similar case and you may would like to have a look at Mike Crowley's answer.

    When Powershell outputs text to the screen, it is an array that you can work with in the pipeline.  for example:

    dnscmd /zoneinfo domain.com | ? {$_ -like '*addr=*'}

    or

    (dnscmd /zoneinfo domain.com) -split '[,]' | ? {$_ -like '*addr=*'}

    For your reference:

    Query DNS secondary zone for Master servers

    https://social.technet.microsoft.com/Forums/sharepoint/en-US/b506fb97-025e-47f9-a7ae-d544568f9fa3/query-dns-secondary-zone-for-master-servers?forum=winserverpowershell

    Regards,

    Zoe


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

    Friday, February 22, 2019 8:01 AM
  • Hi,

    Just checking in to see if the information provided was helpful.

    Please let us know if you would like further assistance.

    Best Regards,

    Zoe


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

    Monday, February 25, 2019 6:11 AM
  • Hi,

    Was your issue resolved?

    If the information provided was helpful, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    Thank you for your understanding and support.

    Best Regards,

    Zoe


    Please remember to mark the replies as 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, February 27, 2019 6:20 AM
  • Going to look into the responses / suggestion now, sorry was away on vacation.  Thanks for replying to the thread, will mark the replies as answer once I test.  Thanks,
    Wednesday, February 27, 2019 4:45 PM
  • Hi,

    We'd love to hear your feedback. By sharing your experience, you can help other community members facing similar problems.

    Thanks for your understanding and efforts.

    Best Regards,

    Zoe


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

    Friday, March 1, 2019 9:27 AM
  • Hi,

    As this thread has been quiet for a while, we will propose the solution as answer. If you need further help, please feel free to reply this post directly so we will be notified to follow it up. You can also choose to unpropose the answer as you wish.

    Thanks for your understanding and cooperation.

    Best Regards,

    Zoe


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

    Monday, March 4, 2019 3:00 AM