GPO-HealthAudit.psm1

#Requires -Version 5.1

<#
.SYNOPSIS
    GPO-HealthAudit module loader.
 
.DESCRIPTION
    Dot-sources all public and private functions from the module directory structure.
    Public functions are exported via the module manifest. Private functions remain
    internal to the module scope.
#>


# Discover and dot-source all private functions first (helpers used by public functions)
$PrivatePath = Join-Path -Path $PSScriptRoot -ChildPath 'Private'
if (Test-Path -Path $PrivatePath) {
    $PrivateFiles = Get-ChildItem -Path $PrivatePath -Filter '*.ps1' -ErrorAction SilentlyContinue
    foreach ($File in $PrivateFiles) {
        try {
            . $File.FullName
            Write-Verbose "Loaded private function: $($File.BaseName)"
        }
        catch {
            Write-Error "Failed to load private function $($File.FullName): $_"
        }
    }
}

# Discover and dot-source all public functions
$PublicPath = Join-Path -Path $PSScriptRoot -ChildPath 'Public'
if (Test-Path -Path $PublicPath) {
    $PublicFiles = Get-ChildItem -Path $PublicPath -Filter '*.ps1' -ErrorAction SilentlyContinue
    foreach ($File in $PublicFiles) {
        try {
            . $File.FullName
            Write-Verbose "Loaded public function: $($File.BaseName)"
        }
        catch {
            Write-Error "Failed to load public function $($File.FullName): $_"
        }
    }
}