private/BootMedia/Steps/Step-BootImageExportPackages.ps1

#Requires -PSEdition Core

function Step-BootImageExportPackages {
    <#
    .SYNOPSIS
        Exports Get-WindowsPackage results to XML and JSON in the build metadata directory.
 
    .NOTES
        Author: David Segura
        Version: 0.1.0
    #>

    [CmdletBinding()]
    param ()

    $CorePath = $global:BuildMedia.CorePath

    Write-OSDeployCoreProgress "Export Get-WindowsPackage to $CorePath\winpe-windowspackage.json"
    $WindowsPackage = $global:BuildMedia.WindowsImage | Get-WindowsPackage
    if ($WindowsPackage) {
        $WindowsPackage | Select-Object * | Export-Clixml -Path "$CorePath\winpe-windowspackage.xml" -Force
        $WindowsPackage | ConvertTo-Json -Depth 5 | Out-File "$CorePath\winpe-windowspackage.json" -Encoding utf8 -Force
        $WindowsPackage | Sort-Object -Property PackageName | Format-Table -AutoSize
    }
}