private/BootMedia/Steps/Step-BootImageStartupProfile.ps1

#Requires -PSEdition Core

function Step-BootImageStartupProfile {
    <#
    .SYNOPSIS
        Copies selected WinPE Startup profiles into the mounted WinPE image.
 
    .DESCRIPTION
        Reads the WinPEStartupProfile paths from $global:BuildMedia and copies each
        JSON file into WinPEStartup\Profiles under the mounted WinPE image.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Change Summary:
        - Initial version.
    #>

    [CmdletBinding()]
    param ()

    $WinPEStartupProfile = $global:BuildMedia.WinPEStartupProfile
    if (-not $WinPEStartupProfile) { return }

    $ProfilesDestPath = Join-Path $global:BuildMedia.MountPath 'WinPEStartup' 'Profiles'
    if (-not (Test-Path -Path $ProfilesDestPath)) {
        New-Item -ItemType Directory -Path $ProfilesDestPath -Force | Out-Null
    }

    foreach ($Item in $WinPEStartupProfile) {
        if (Test-Path -LiteralPath $Item) {
            Write-OSDeployCoreProgress "winpestartup-profile: $Item"
            Copy-Item -LiteralPath $Item -Destination $ProfilesDestPath -Force
        }
        else {
            Write-Warning "WinPE Startup Profile not found: $Item"
        }
    }
}