Src/Private/Get-AbrSPSections.ps1

#region --- Section Orchestrators ---

function Get-AbrSPSharingSection {
    [CmdletBinding()]
    param ([Parameter(Mandatory)][string]$TenantId)

    if ($InfoLevel.SharingPolicy -lt 1 -and $InfoLevel.ExternalAccess -lt 1) { return }

    Section -Style Heading1 'Sharing & External Access' {
        Paragraph "The following section documents how content in SharePoint Online and OneDrive for Business can be shared with people inside and outside your organisation."
        BlankLine

        if ($InfoLevel.SharingPolicy -ge 1) {
            Write-Host ' - Working on Sharing Policy sub-section.'
            Get-AbrSPSharingPolicy -TenantId $TenantId
        }

        if ($InfoLevel.ExternalAccess -ge 1) {
            Write-Host ' - Working on External Access Controls sub-section.'
            Get-AbrSPExternalAccess -TenantId $TenantId
        }
    }
}

function Get-AbrSPContentSection {
    [CmdletBinding()]
    param ([Parameter(Mandatory)][string]$TenantId)

    if ($InfoLevel.SiteCollections -lt 1 -and $InfoLevel.OneDrive -lt 1) { return }

    Section -Style Heading1 'Content & Storage' {
        Paragraph "The following section documents the SharePoint Online site collections and OneDrive for Business drives for tenant $TenantId."
        BlankLine

        if ($InfoLevel.SiteCollections -ge 1) {
            Write-Host ' - Working on Site Collections sub-section.'
            Get-AbrSPSiteCollections -TenantId $TenantId
        }

        if ($InfoLevel.OneDrive -ge 1) {
            Write-Host ' - Working on OneDrive for Business sub-section.'
            Get-AbrSPOneDrive -TenantId $TenantId
        }
    }
}

function Get-AbrSPComplianceSection {
    [CmdletBinding()]
    param ([Parameter(Mandatory)][string]$TenantId)

    if ($InfoLevel.Compliance -lt 1) { return }

    Section -Style Heading1 'Compliance & Data Governance' {
        Paragraph "The following section documents the compliance, audit, and data governance configuration for SharePoint Online and OneDrive for Business in tenant $TenantId."
        BlankLine

        Write-Host ' - Working on Compliance sub-section.'
        Get-AbrSPCompliance -TenantId $TenantId
    }
}

function Get-AbrSPSecurityPostureSection {
    [CmdletBinding()]
    param ([Parameter(Mandatory)][string]$TenantId)

    # Security posture only has value when at least one compliance framework is enabled
    # and data has been collected. It runs last so all $script:E8AllChecks / $script:CISAllChecks
    # are fully populated.
    $hasE8Data  = ($script:IncludeACSCe8      -and $script:E8AllChecks  -and $script:E8AllChecks.Count  -gt 0)
    $hasCISData = ($script:IncludeCISBaseline  -and $script:CISAllChecks -and $script:CISAllChecks.Count -gt 0)

    if (-not ($hasE8Data -or $hasCISData)) {
        Write-Host '- Skipping Security Posture section (no compliance framework data collected).' -ForegroundColor DarkGray
        return
    }

    Write-Host '- Working on Security Posture & Advisory section.'
    Get-AbrSPSecurityPosture -TenantId $TenantId
}

#endregion