Windows Server 2016 Directory Services ForestMode Enumeration - 'Unknown'


  • Namespace:   System.DirectoryServices.ActiveDirectory
    OS - Windows Server 2016 RTM
    Role - Directory Services
    Issue Category - .Net Framework ForestMode Enumeration
    .Net Version - .NET Framework 4.6.2
    Issue- When trying to enumerate the "forestmode" of the '' forest from a stand-alone member server (Windows Server 2016 RTM non-domain joined server) using the below commands, the output comes out as 'Unknown'. However, when I run the (Get-ADForest).ForestMode on the root domain controller itself, the output comes out as 'Windows2016Forest'. Why is this discrepancy? What is the solution, if there is one? When can we except the correct value be returned via the .Net way?

    $ForestContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext('forest','','','Password')
    $ForestInfo = [System.DirectoryServices.ActiveDirectory]::GetForest($forestcontext)

    • Edited by Tarun Rajvanshi Tuesday, January 17, 2017 2:16 PM updated .net version
    Tuesday, January 17, 2017 2:10 PM

All replies

  • Hi,
    I am not quite sure what the problem you are suffering is.
    Based on my understanding of ForestMode Enumeration, if you run ForestMode Enumeration on a non-domain server, as there is no forest running, the output is unknown which seems to be reasonable for me. Please see:
    In addition, I would suggest you have a try posting questions in the .Net Framework forum:
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Best regards,

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Wednesday, January 18, 2017 6:12 AM
  • Hi,
    Thanks for posting the reply. My apologies if I did not elaborate the problem correctly. However, in my case the forest is running ( I am trying to enumerate the forestmode of the forest from a standalone server (which is not part of domain as yet), while creating a directorycontext object by authenticating  with the enterprise admin of forest. I expect "Windows2016Forest" as the output, however it comes out as 'Unknown'. Interestingly when I run Get-ADForest on the DC of, i do get the desired output, which makes me believe that .Net is not returning the correct the value for the forestmode. And is only happening in the case of Windows Server 2016 DCs. The DCs of earlier operating systems does return the correct values as shown in the article you have shared in your reply.

    BTW, i have posted the same question on .net forum as well.


    Tarun Rajvanshi

    Wednesday, January 18, 2017 8:36 AM
  • Hi Tarun,
    Appreciate for your feedback and update, and we are glad to hear that you have also posted in related forum, hope that some good share about this issue will be returned.
    And we will keep our eyes on this thread,too and you will receive update if any is done.
    Best regards,

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Thursday, January 19, 2017 2:09 AM