For some reason, with all the power of the internets, this answer was nowhere to be easily found.
I needed to be able to count the number of (Domain Controllers) DC's in our forest, and also for a specific domain. It's a simple PowerShell script ... here is what I used
cls
$domains = (Get-ADForest).Domains;
foreach ($domain in $domains)
{
Write-Host $domain
(Get-ADDomain -Identity $domain | select -ExpandProperty ReplicaDirectoryServers).Count;
Write-Host "";
$totalCount = $totalCount + (Get-ADDomain -Identity $domain | select -ExpandProperty ReplicaDirectoryServers).Count;
}
Write-Host "Total domain controller count is: "$totalCount
This is the blog of DJ (@gkrew) and Brad, two guys who are just engineers on a messaging team supporting Microsoft Exchange Server. DJ is an IT Pro with experience as an Enterprise System Administrator in Microsoft Windows and Unix. Brad is a self-taught coder who develops code to assist with Exchange Administration using C# and PowerShell. There will be posts about Exchange, PowerShell, Active Directory, C# and scripts that you can use in your job as well as anything IT related.
Showing posts with label Domain Controllers. Show all posts
Showing posts with label Domain Controllers. Show all posts
Tuesday, February 10, 2015
Subscribe to:
Posts (Atom)