private/Initialize-OSDeployWinPEDrivers.ps1

function Initialize-OSDeployWinPEDrivers {
    <#
    .SYNOPSIS
        Initializes the OSDeployWinPEDrivers functions by applying PSDefaultParameterValues.
 
    .DESCRIPTION
        Applies a two-layer PSDefaultParameterValues system at module load time:
 
        Layer 1 - Module defaults: flat key-value pairs in default.json (module root)
        Layer 2 - User overrides: $Script:OSDeployWinPEDriversUserDefaults (OSDRe\PSDefaultParameterValues.json)
 
        The user override file is loaded last, so any key it defines overwrites the module
        default for the same key. Keys present only in the module defaults are unaffected.
 
        Single-line (//) and block (/* */) comments are stripped before parsing so that
        annotated JSON files are supported.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        None.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Change Summary:
    #>

    [CmdletBinding()]
    param ()

    # Normalize sources: add optional properties with defaults so they can be accessed
    # safely under Set-StrictMode -Version Latest without PropertyNotFoundException.
    foreach ($src in $global:OSDeployModule.WinPEDrivers.PSObject.Properties) {
        $v = $src.Value
        if (-not $v.PSObject.Properties['Disabled'])    { $v | Add-Member -NotePropertyName 'Disabled'     -NotePropertyValue $false }
        if (-not $v.PSObject.Properties['UpdateUri'])   { $v | Add-Member -NotePropertyName 'UpdateUri'    -NotePropertyValue $null  }
        if (-not $v.PSObject.Properties['DownloadUri']) { $v | Add-Member -NotePropertyName 'DownloadUri'  -NotePropertyValue $null  }
    }

    # Path to the module-scoped PSDefaultParameterValues
    $Script:OSDeployWinPEDriversDefaults = Join-Path $script:OSDeployModuleBase 'core\PSDefaultParameterValues.json'

    # Path to the user-scoped dynamic driver catalog
    $Script:OSDeployWinPEDriversUserConfig = Join-Path $Script:OSDeployCorePath 'cache\config\winpedrivers.json'

    # Path to the user-scoped PSDefaultParameterValues
    $Script:OSDeployWinPEDriversUserDefaults = Join-Path $Script:OSDeployCoreRepositoryPath 'PSDefaultParameterValues.json'

    Set-OSDeployPSDefaultParameterValues -ModuleDefaultsPath $Script:OSDeployWinPEDriversDefaults -UserDefaultsPath $Script:OSDeployWinPEDriversUserDefaults
}