LLI Wiki — My Digital Knowledge Base

List Active Directory domain controllers with PowerShell

Check the ActiveDirectory module and list, display, export or count domain controllers with PowerShell.

PowerShell and the ActiveDirectory module can list the domain controllers of an Active Directory domain in a single command line.

Check the ActiveDirectory module

Without options, Get-Module shows whether the module is loaded in the session. The -ListAvailable option shows whether it is installed.

Get-Module -Name ActiveDirectory
Get-Module -Name ActiveDirectory -ListAvailable

Load the module if needed

Import-Module -Name ActiveDirectory

List the domain controllers

Get-ADDomainController -Filter * | Select-Object Name

Show the result in a graphical window:

Get-ADDomainController -Filter * | Select-Object Name | Out-GridView

Export the result to a text file:

Get-ADDomainController -Filter * | Select-Object Name | Out-File C:\temp\domain-controllers.txt

Count the domain controllers:

Get-ADDomainController -Filter * | Select-Object Name | Measure-Object

Notes

Mastodon LLIMastodon SocialFosstodon