I have been working on an AD Statistics script for a little while now that provides some basic information about the AD environment.
This Powershell code gathers data from the Active Directory domain for groups and displays some group statistics.
Import-Module ActiveDirectory
Write-Output “Getting list of AD Groups `r “[array]$AllADGroups = Get-ADGroup -Filter * -Properties *
$AllADGroupsCount = $AllADGroups.Count
Write-Output “There are $AllADGroupsCount Total groups in AD `r “[array]$ADUniversalGroups = $AllADGroups | Where {$_.GroupScope -eq “Universal” }
$ADUniversalGroupsCount = $ADUniversalGroups.Count
$PCTofTotal = $ADUniversalGroupsCount / $AllADGroupsCount
$PCTofTotal = “{0:p2}” -f $PCTofTotal
Write-Output “There are $ADUniversalGroupsCount Universal groups in AD ($PCTofTotal of all groups) `r “[array]$ADGlobalGroups = $AllADGroups | Where {$_.GroupScope -eq “Global” }
$ADGlobalGroupsCount = $ADGlobalGroups.Count
$PCTofTotal = $ADGlobalGroupsCount / $AllADGroupsCount
$PCTofTotal = “{0:p2}” -f $PCTofTotal
Write-Output “There are $ADGlobalGroupsCount Global groups in AD ($PCTofTotal of all groups) `r “[array]$ADDomainLocalGroups = $AllADGroups | Where {$_.GroupScope -eq “DomainLocal” }
$ADDomainLocalGroupsCount = $ADDomainLocalGroups.Count
$PCTofTotal = $ADDomainLocalGroupsCount / $AllADGroupsCount
$PCTofTotal = “{0:p2}” -f $PCTofTotal
Write-Output “There are $ADDomainLocalGroupsCount Domain Local groups in AD ($PCTofTotal of all groups) `r “[array]$ADSecurityGroups = $AllADGroups | Where {$_.GroupCategory -eq “Security” }
$ADSecurityGroupsCount = $ADSecurityGroups.Count
$PCTofTotal = $ADSecurityGroupsCount / $AllADGroupsCount
$PCTofTotal = “{0:p2}” -f $PCTofTotal
Write-Output “There are $ADSecurityGroupsCount Security groups in AD ($PCTofTotal of all groups) `r “[array]$ADMESecurityGroups = $ADSecurityGroups | Where {$_.Mail -ne $Null }
$ADMESecurityGroupsCount = $ADMESecurityGroups.Count
$PCTofTotal = $ADMESecurityGroupsCount / $AllADGroupsCount
$PCTofTotal = “{0:p2}” -f $PCTofTotal
Write-Output “There are $ADSecurityGroupsCount Mail-Enabled Security groups in AD ($PCTofTotal of all groups) `r “[array]$ADDistributionGroups = $AllADGroups | Where {$_.GroupCategory -eq “Distribution” }
$ADDistributionGroupsCount = $ADDistributionGroups.Count
$PCTofTotal = $ADDistributionGroupsCount / $AllADGroupsCount
$PCTofTotal = “{0:p2}” -f $PCTofTotal
Write-Output “There are $ADDistributionGroupsCount Distribution groups in AD ($PCTofTotal of all groups) `r “[array]$ADMEnotUniGroups = $AllADGroups | Where { ($_.GroupCategory -eq “Distribution”) -AND ($_.GroupScope -ne “Universal” ) }
$ADMEnotUniGroupsCount = $ADMEnotUniGroups.Count
$PCTofTotal = $ADMEnotUniGroupsCount / $AllADGroupsCount
$PCTofTotal = “{0:p2}” -f $PCTofTotal
Write-Output “There are $ADMEnotUniGroupsCount Distribution groups that are not Universal groups in AD ($PCTofTotal of all groups) `r “