private/Initialize-OSDeployCoreDrivers.ps1

function Initialize-OSDeployCoreDrivers {
    <#
    .SYNOPSIS
        Initializes OSDeploy WinPE driver configuration
 
    .DESCRIPTION
        Adds Disabled, UpdateUri, and DownloadUri properties to WinPE driver source objects
        that do not already define them. This permits strict-mode access without replacing
        values supplied by module metadata.
 
        The function also sets the module-scoped user driver catalog path to
        cache\config\winpedrivers.json below the current OSDeployCore path.
 
    .EXAMPLE
        PS> Initialize-OSDeployCoreDrivers
 
        Normalizes the loaded WinPE driver metadata and sets the user catalog path.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        None.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 1.0.0
        Date: 2026-08-28
 
        This function modifies $global:OSDeployModule.WinPEDrivers and sets
        $Script:OSDeployWinPEDriversUserConfig.
 
        Change Summary:
            - Limited initialization to WinPE driver-specific configuration.
    #>

    [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
        # Older module.json entries may omit these fields; add them without replacing supplied values.
        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 user-scoped dynamic driver catalog
    $Script:OSDeployWinPEDriversUserConfig = Join-Path $Script:OSDeployCorePath 'cache\config\winpedrivers.json'
}