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.
1 2 3 4 5 6 7 8 |
# 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.
1 |
Get-ADDomainController -filter * | Select-Object name |
Visualize the results using a Graphical Window.
1 |
Get-ADDomainController -filter * | Select-Object name | out-GridView |
Export the results into a text file.
1 |
Get-ADDomainController -filter * | Select-Object name| Out-File c:\typeyourpathhere |
List the total count of all the Domain Controllers in the AD Domain.
1 |
Get-ADDomainController -filter * | Select-Object name | Measure-Object |
More posts on PowerShell and Active Directory:
- Check AD Replication Status using PowerShell ( one-liners )
- Transfer/Seize FSMO Roles using Powershell ( one-liners )
- Use PowerShell to join a Windows Server Core to Active Directory (one-liners)
Thanks for reading!