How to get all Domain Controllers in Active Directory Forest with Powershell

22 January,2021 by Jack Vamvas

Question: I need to configure some applications to use some Domain Controllers . To establish the address - I need to list the Domain Controllers within the Active Directory Forest. Is there a method in Powershell to create a list of Domain Controllers ?


Answer: Powershell has a flexible group of Powershell cmdlets to get information about the Active Directory . Combining Get-ADForest and Get-ADDomainController  will create a recordset 

Here is a sample code snippet :


(Get-ADForest).Domains | % { Get-ADDomainController -Discover -DomainName  $_ } | % { Get-ADDomainController -server $_.Name -filter * } | Select Name, Domain, Forest, IPv4Address, Site | ft


Read more on Powershell and Active Directory 

How to find Active Directory users with Get-ADUser search filter

How to get the Active Directory groups membership for user with Powershell

How to Export Active Directory Group Members with Powershell Get-ADGroupMember

SQL Server – Powershell Active Directory search

Author: Jack Vamvas (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to get all Domain Controllers in Active Directory Forest with Powershell | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer