PowerTip: Use PowerShell to Find Name & OS Version of Domain Controllers

Summary: Use Windows PowerShell to find the name and operating system version of all your domain controllers.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find the name and operating system version of all my domain controllers?

Hey, Scripting Guy! Answer Use the Get-ADDomainController cmdlet from the Active Directory module and a wild card filter to select all domain controllers. Then pipe the results to the Select-Object cmdlet and choose the Name and OperatingSystem properties.

Get-ADDomainController -Filter * | select name, operatingsystem

Comments (7)

  1. mredwilson says:

    @Derrick The Get-ADDomainController cmdlet has a -DomainName parameter that permits you to specify the domain name. You could populate that value with your childdomains. The Get-ADDOmain cmdlet will return childdomains.

  2. bshwjt says:

    Get-ADDomainController -Filter * | select name, operatingsystem,HostName,site,IsGlobalCatalog,IsReadOnly | Export-Csv c:dcinventory.csv

  3. Derrick says:

    How can I pull this information from all child domains?

  4. Wunth says:

    If you get the error
    Get-ADDomainController : Unable to find a default server with Active Directory Web Services running
    Then it’s possible that the Domain environment is pre Server 2008 R2 judging by this post
    But you can’t be sure until you’re able to query the OS version 🙂

  5. TiDu says:

    I’ve been using this cmdlet in a script for over a year now, but since last week it’s stopped working (possibly due to Windows Updates?). When I run Get-ADDomainController -Filter * now, I get the error message; "Directory Object not found". Is anyone
    else seeing this? (DCs are Windows 2012 R2 by the way).

  6. thomas says:

    Hi TiDu, I experienced the same, Get-ADDomainController -Filter * is no longer working since a few days on 2012 R2 DCs.

Skip to main content