Saturday, August 11, 2018

PowerShell Script: Get AD Domain and Forest functional level

Simple script to show Active Directory domain and forest functional level, FSMO roles, all sites in the forest, Global Catalog servers.

Link for download
.\Get-ADInfo.ps1

Example of usage:
[PS].\Get-ADInfo.ps1



Get-ADInfo.ps1
#.\Get-ADInfo.ps1

#Forest Info
$ADForest=Get-ADForest

write-host
Write-Host "Forest Name             :" $ADForest.Name
write-host "Forest Functional Level :" $ADForest.ForestMode
Write-Host "Schema master           :" $ADForest.SchemaMaster
Write-Host "Domain naming master    :" $ADForest.DomainNamingMaster

#Domain Info
foreach ($Domain in $ADForest.Domains){
    write-host
    $ADDomain=Get-ADDomain $Domain
    write-host "Domain Name                  :" $Domain
    write-host "Distinguished Name           :" $ADDomain.DistinguishedName
    write-host "Domain Functional Level      :" $ADDomain.DomainMode
    write-host "Domain NetBIOS Name          :" $ADDomain.NetBIOSName
    write-host "PDC Emulator                 :" $ADDomain.PDCEmulator
    write-host "RID master                   :" $ADDomain.RIDMaster
    write-host "Infrastructure master        :" $ADDomain.InfrastructureMaster
    write-host "Domain Controllers Container :" $ADDomain.DomainControllersContainer
    write-host "Computers Container          :" $ADDomain.ComputersContainer
    write-host "Users Container              :" $ADDomain.UsersContainer
}

#Sites
write-host
write-host "Active Directory Sites:"
    foreach ($ADSite in $ADForest.Sites){
        Write-Host "   " $ADSite
    }


#GlobalCatalogs
write-host
write-host "Global Catalog servers:"
    foreach ($GlobalCatalogs in $ADForest.GlobalCatalogs){
        Write-Host "   " $GlobalCatalogs
    }

Write-Host

Link for download
.\Get-ADInfo.ps1



No comments:

Post a Comment