private/Step-BuildBootLogWindowsDriver.ps1

#Requires -PSEdition Core

function Step-BuildBootLogWindowsDriver {
    <#
    .SYNOPSIS
        Exports and formats driver metadata from the mounted Windows image
 
    .DESCRIPTION
        Gets drivers from global BuildMedia.WindowsImage and, when results exist,
        exports full driver properties as CLIXML and JSON under global
        BuildMedia.CorePath. It also sorts selected driver properties and writes a
        formatted table to the success stream.
 
    .EXAMPLE
        PS> Step-BuildBootLogWindowsDriver
 
        Writes driver metadata files and emits a formatted driver table.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        System.Object. Emits PowerShell formatting records produced by Format-Table when drivers exist.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 0.1.0
        Date: 2026-08-28
 
        Requires global BuildMedia.WindowsImage and BuildMedia.CorePath and the
        Get-WindowsDriver cmdlet. Writes winpe-windowsdriver.xml and
        winpe-windowsdriver.json when driver records are returned.
    #>

    [CmdletBinding()]
    param ()

    $CorePath = $global:BuildMedia.CorePath

    Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [INFO] 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
    }
}