Private/Show-ForestOverview.ps1

<#
.SYNOPSIS
Displays an overview of domains and domain controllers in the current forest.
 
.DESCRIPTION
Collects domain details, domain classifications, controller counts, and preferred controllers,
then displays a formatted forest overview.
 
.COMPONENT
Category: Sub Function
 
.FUNCTIONALITY
Combines domain details, domain types, controller counts, and preferred DCs in a forest summary.
#>

function Show-ForestOverview {

    ################################################################################
    ##### #####
    ##### Collect info about the current foest, incl. the best DC #####
    ##### #####
    ################################################################################

    Param([string] $param1, [string] $param2)

    $Info = Measure-FunctionRuntime -Begin
    $CurrentFunction = $Info.FunctionName
    
    $Script:DoaminTypes = Get-DomainType
    $Script:DCsPerDomain = Get-NumberOfDCs
    $Script:BestDCs = Set-BestDomainController
    $Forest = Get-ADForest

    $AllDomainsDetails = $Forest.Domains | ForEach-Object {
        Get-DomainPWDetails -DomainName $_
    }

    Write-AS2GoOutput -Type Header -Message "Identified the following domains"

    $overview = $AllDomainsDetails |
    Select-Object `
    @{N = 'Domain'; E = { $_.NetBIOSName } },
    @{N = 'DomainType'; E = { $_.DomainType } },
    @{N = 'EnabledUsers'; E = { $_.EnabledUser } },
    @{N = 'DomainMode'; E = { $_.DomainMode } },
    @{N = 'MachineAccountQuota'; E = { $_.MachineAccountQuota } },
    @{N = 'RWDCs'; E = { $Script:DCsPerDomain[$_.DomainFQDN].RWDC } },
    @{N = 'RODCs'; E = { $Script:DCsPerDomain[$_.DomainFQDN].RODC } },
    @{N = 'Best DC'; E = { $Script:BestDCs[$_.DomainFQDN] } },
    @{N = 'FQDN'; E = { $_.DomainFQDN } }

    $FQDN = (Get-ADDomain).DNSRoot
    Set-TextMarker -OldFormat $overview -column 'FQDN' -value $FQDN -color $Script:fgcC


    if ($null -ne $script:ErrorForestInfo ) {
        Write-AS2GoOutput -Type Error -Message $script:ErrorForestInfo
    }

    Measure-FunctionRuntime -End -Details $Info
}