M365-QuickAssess.psm1

###################################################################################################
# Module: M365-QuickAssess.psm1
# Author: Ryan Holderread - Rackspace Technology
# Repository: https://github.com/HennepinCrawler/M365-QuickAssess
# Version: 3.0.3
# Last Updated: 2026-03-25
#
# Description:
# Root module file. Dot-sources all Private, Public, and Workload functions
# and exports only the public entry point.
###################################################################################################

# -------------------------------------------------------------------
# Module-level shared context
# Populated by Connect-GraphService, consumed by all workloads
# -------------------------------------------------------------------
$script:Context = @{
    TenantId         = $null
    TenantPrefix     = $null
    TenantShortName  = $null
    GraphAccount     = $null
    RunStamp         = $null
    OutputPath       = $null
    WorkloadLabel    = $null
    SPOAdminUrl      = $null
}

# -------------------------------------------------------------------
# Load Private functions (internal helpers, not exported)
# -------------------------------------------------------------------
$Private = Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" -ErrorAction SilentlyContinue

foreach ( $file in $Private )
{
    try
    {
        . $file.FullName
    }
    catch
    {
        Write-Warning "M365-QuickAssess: Failed to load private function '$( $file.Name )': $_"
    }
}

# -------------------------------------------------------------------
# Load Workload functions (internal, not exported)
# -------------------------------------------------------------------
$Workloads = Get-ChildItem -Path "$PSScriptRoot\Workloads\*.ps1" -ErrorAction SilentlyContinue

foreach ( $file in $Workloads )
{
    try
    {
        . $file.FullName
    }
    catch
    {
        Write-Warning "M365-QuickAssess: Failed to load workload '$( $file.Name )': $_"
    }
}

# -------------------------------------------------------------------
# Load Public functions (exported below)
# -------------------------------------------------------------------
$Public = Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" -ErrorAction SilentlyContinue

foreach ( $file in $Public )
{
    try
    {
        . $file.FullName
    }
    catch
    {
        Write-Warning "M365-QuickAssess: Failed to load public function '$( $file.Name )': $_"
    }
}

# -------------------------------------------------------------------
# Export only the public entry point
# Keeps the module surface clean — clients only see Invoke-M365QuickAssess
# -------------------------------------------------------------------
Export-ModuleMember -Function ( $Public | Select-Object -ExpandProperty BaseName )