private/Select-OSDeployCoreWinpeDrivers.ps1
|
#Requires -PSEdition Core function Select-OSDeployCoreWinpeDrivers { <# .SYNOPSIS Selects WinPE driver folders for an OSDeploy Boot build .DESCRIPTION Enumerates package directories beneath the Boot-Assets winpedrivers-amd64 and winpedrivers-arm64 directories. Only package directories that contain at least one INF file are eligible. Results are sorted and displayed in an Out-GridView multi-selection picker. Canceling the picker returns no object. This function returns selected directory metadata. It does not copy or modify drivers. .PARAMETER Architecture Limits results to amd64 or arm64. When omitted, both architectures are eligible. .PARAMETER SkipWifiDrivers Excludes package directory names containing wifi or wireless before displaying the picker. .EXAMPLE PS> Select-OSDeployCoreWinpeDrivers -Architecture amd64 -SkipWifiDrivers Displays amd64 driver folders containing INF files, excluding Wi-Fi packages. .INPUTS None. This function does not accept pipeline input. .OUTPUTS System.Management.Automation.PSCustomObject[]. Returns selected objects with Type, Name, Architecture, FullName, and LastWriteTime properties, or no object when none are selected. .NOTES Author: David Segura Company: Recast Software Version: 0.1.0 Date: 2026-08-28 .LINK Build-OSDeployBoot #> [CmdletBinding()] param ( [ValidateSet('amd64', 'arm64')] [System.String] $Architecture, [System.Management.Automation.SwitchParameter] $SkipWifiDrivers ) $driverItems = @() $driverRoots = @( [PSCustomObject]@{ Architecture = 'amd64'; Path = Join-Path $script:OSDeployBootAssetsPath 'winpedrivers-amd64' } [PSCustomObject]@{ Architecture = 'arm64'; Path = Join-Path $script:OSDeployBootAssetsPath 'winpedrivers-arm64' } ) foreach ($driverRoot in $driverRoots) { $driverItems += Get-ChildItem -LiteralPath $driverRoot.Path -Directory -ErrorAction SilentlyContinue | Where-Object { Get-ChildItem -Path $_.FullName -Filter '*.inf' -File -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 } | Select-Object @{Name = 'Type'; Expression = { 'winpe-driver' } }, Name, @{Name = 'Architecture'; Expression = { $driverRoot.Architecture } }, FullName, LastWriteTime } # Filter to valid architectures $driverItems = $driverItems | Where-Object { ($_.Architecture -eq 'amd64') -or ($_.Architecture -eq 'arm64') } if ($Architecture) { $driverItems = $driverItems | Where-Object { $_.Architecture -eq $Architecture } } if ($SkipWifiDrivers) { $driverItems = $driverItems | Where-Object { $_.Name -notmatch 'wifi|wireless' } } $driverItems = $driverItems | Sort-Object -Property Name, FullName if ($driverItems -and $driverItems.Count -gt 0) { Write-HostDateTimeDarkGray 'Select WinPE Drivers to add to this build (Cancel to skip)' $selected = $driverItems | Out-GridView -PassThru -Title 'Select WinPE Drivers to add to this build (Cancel to skip)' return $selected } return $null } |