private/BootMedia/Steps/Step-BootImageExportDrivers.ps1

#Requires -PSEdition Core

function Step-BootImageExportDrivers {
    <#
    .SYNOPSIS
        Exports Get-WindowsDriver 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-WindowsDriver to $CorePath\winpe-windowsdriver.json"
    $WindowsDriver = $global:BuildMedia.WindowsImage | Get-WindowsDriver
    if ($WindowsDriver) {
        $WindowsDriver | Select-Object * | Export-Clixml -Path "$CorePath\winpe-windowsdriver.xml" -Force
        $WindowsDriver | ConvertTo-Json -Depth 5 | Out-File "$CorePath\winpe-windowsdriver.json" -Encoding utf8 -Force
        $WindowsDriver | Sort-Object ProviderName, CatalogFile, Version |
            Select-Object ProviderName, CatalogFile, Version, Date, ClassName, BootCritical, Driver,
                @{ Name = 'FileRepository'; Expression = { ($_.OriginalFileName.split('\')[-2]) } } |
            Format-Table -AutoSize
    }
}