PowerShell Genie

Report domain controllers

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

List AD domain controllers with their sites, IPv4 addresses, operating systems, and global-catalog status using Get-ADDomainController.

The script

1PS> Get-ADDomainController -Filter * | Select-Object HostName,Site,IPv4Address,OperatingSystem,IsGlobalCatalog

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 HostName Site IPv4Address OperatingSystem IsGlobalCatalog
    2 -------- ---- ----------- --------------- ---------------
    3 DC01.contoso.example Default-First-Site-Name 10.20.30.11 Windows Server 2022 True
    Inspect this example’s structure

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

    Get-ADDomainController -Filter * | Select-Object HostName,Site,IPv4Address,OperatingSystem,IsGlobalCatalog
    1. Stage 1Get-ADDomainController-Filter
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      Get-ADDomainController with -Filter * enumerates the controllers, and the projection reports each host name with its AD site, IPv4 address, operating system version, and whether that server holds a global catalog.

      Adapting it

      Swap -Filter * for -Discover -Service PrimaryDC when the only question is which server currently answers as PDC emulator for the domain the session is bound to.

      Requirements

      ActiveDirectory module.

      If the result is unexpected

      A domain controller is missing from the inventory.

      The query may target a different domain or use credentials that cannot discover the intended controllers.

      1. Confirm the domain and query a known controller directly before comparing the full list.

      Validate the result

      The inventory matches the selected domain and identifies the server used for discovery.

      Keep the check reliable

      Make domain and server parameters explicit in recurring inventory jobs.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideReport domain controllers

      List AD domain controllers with their sites, IPv4 addresses, operating systems, and global-catalog status using Get-ADDomainController.