AD powershell domain controllers from a site

Can anyone tell me how to get all the domain controllers from a certain site. I am using the command below but its giving me one DC at a time. I would like to be able to get them all at once.

Get-ADDomainController -Discover  -SiteName <  >
Who is Participating?
From the help for Get-ADDomainController.
"To search for and retrieve more than one domain controller, use the Filter parameter."  So to filter by site you have something like below.
Get-ADDomainController -Filter { Site -eq "Default-First-Site-Name" }
Ganesh Kumar ASr Infrastructure SpecialistCommented:
These are the powershell commands will help you to get the list of DC on specific site.

Get-ADDomainController -Discover -Site "Default-First-Site-Name"

Get-ADDomainController -Filter  { isGlobalCatalog -eq $true -and Site -eq "Default-First-Site-Name" }

$allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.