List Domain Controllers Forest-Wide


In a previous post, I’ve put a snippet using powershell to be able to list domain controllers forest-wide. Here’s a variation if you have some legacy Powershell 2.0, etc. The algorithm takes advantage of the ADSI inteface and the AD Searcher object instead of relying on some built-in powershell cmdlets.

We first get the RootDSE object, from which we extract the name of the forest.

From there we retrieve all the NTDS Settings objects from the full forest and we strip the NTDS Settings prefix to get only the distinguished name of the computer object of the Domain Controller.

Leave a comment

Your email address will not be published. Required fields are marked *