PowerShell Genie

Get-ADDomainController

Use Get-ADDomainController to retrieve domain controllers in a domain or forest, with their roles, site and status.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-ADDomainController

Syntax

1PS> Get-ADDomainController [-Identity] <ADDomainController> [-Filter <String>] [-Discover] [-Service <ADDiscoverableService[]>] [-DomainName <String>] [-SiteName <String>] [-Server <String>] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Get-ADDomainController [-Identity] <ADDomainController> [-Filter <String>] [-Discover] [-Service <ADDiscoverableService[]>] [-DomainName <String>] [-SiteName <String>] [-Server <String>] [<CommonParameters>]
  1. Stage 1Get-ADDomainController-Identity -Filter -Discover -Service -DomainName -SiteName -Server

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Get-ADDomainController -Filter *

    1PS> Get-ADDomainController -Filter * | Select-Object Name, Site, IsGlobalCatalog, IsReadOnly
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name  Site                     IsGlobalCatalog  IsReadOnly
    ----  ----                     ---------------  ----------
    DC01  Default-First-Site-Name  True             False
    DC02  Default-First-Site-Name  True             False

    Get-ADDomainController -Filter * (2)

    1PS> Get-ADDomainController -Filter * | Select-Object Name, OperationMasterRoles
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name  OperationMasterRoles
    ----  --------------------
    DC01  {PDCEmulator, RIDMaster, SchemaMaster, DomainNamingMaster}
    DC02  {InfrastructureMaster}

    Get-ADDomainController -Discover

    1PS> Get-ADDomainController -Discover -Service PrimaryDC
    Show reference output

    Sample output · fictional data, shaped like the real thing

    HostName          Site          IPv4Address  IsGlobalCatalog
    --------          ----          -----------  ---------------
    DC01.corp.local   Default-Site  10.20.30.10  True
    DC02.corp.local   Default-Site  10.20.30.11  True

    Parameters

    Parameter definitions:

    • -Identity
    • -Filter
    • -Discover
    • -Service
    • -DomainName
    • -SiteName
    • -Server

    Get-ADDomainController on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-ADDomainController when you need to retrieve domain controllers in a domain or forest, with their roles, site and status. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Discovery returning an unexpected site needs checking the client's subnet-to-site mapping. Verify site information before selecting a controller for a locality-sensitive operation. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-ADReplicationPartnerMetadata. Get-ADDomainController discovers domain controllers; Get-ADReplicationPartnerMetadata examines replication partners. Finding a controller does not establish that its directory partitions are up to date. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-ADDomainController reference on Microsoft Learn

    Recap

    Get-ADDomainController Use Get-ADDomainController to retrieve domain controllers in a domain or forest, with their roles, site and status.

    Next: Get-ADComputer
    Genie guideGet-ADDomainController

    Use Get-ADDomainController to retrieve domain controllers in a domain or forest, with their roles, site and status. The console below is pre-loaded — run it, then change a value and run it again.