Reading Time: < 1 minute

Yesterday, I needed to quickly list all the names of all the Domain Controllers in the AD Domain and the total count. Fortunately, the following Powershell cmdlet saved me a lot of time and I wanted to share it with you.

First of all, you need to make sure that the following module is loaded in order to use the cmdlet that meets our needs.

# Check if the ActiveDirectory module is Loaded
Get-Module -Name ActiveDirectory

# Check if the ActiveDirectory module is available
Get-Module -Name ActiveDirectory -ListAvailable

# Import the ActiveDirectory module if it is not loaded
Import-Module -Name ActiveDirectory

List of all the Domain Controllers in the AD Domain.

Get-ADDomainController -filter * | Select-Object name

Visualize the results using a Graphical Window.

Get-ADDomainController -filter * | Select-Object name | out-GridView

Export the results into a text file.

Get-ADDomainController -filter * | Select-Object name| Out-File c:\typeyourpathhere

List the total count of all the Domain Controllers in the AD Domain.

Get-ADDomainController -filter * | Select-Object name | Measure-Object

More posts on PowerShell and Active Directory:

Thanks for reading my blog!

Feel free to drop your comment or question below.