Retrieve Active Directory domain controller OS forest wide
This script uses the information stored in the Active Directory database to retrieve the domain controller FQDNs qnd their operating system. The script follow the steps below
- enumerate the domain names in the current forest
- list the domain controllers in each domain
- retrieve FQDN and OS information for each DC
#init
$array = @()
#list domains in the forest
$domains = (Get-ADForest).Domains
$domains | % {
$dnsDomainName = $_
$DomainControllersOU = (Get-ADDomain $dnsDomainName).DomainControllersContainer
$array += Get-ADcomputer -SearchBase $DomainControllersOU -server $dnsDomainName -filter * -Properties DNSHostName,OperatingSystem | select DNSHostName,OperatingSystem
}
$array
My Powershell script categories
- Active Directory
- Cluster
- Database
- Exchange
- Files and folders
- Hardware
- Network
- Operating System
- PKI
- SCCM
- Service and process
- Tips
- VMWare
Retrieve Active Directory domain controller OS forest wide