Add option to skip driver installation during deployment

Allows users to bypass driver installation by entering 0 at the selection prompt, providing flexibility for deployments that don't require driver updates.

Introduces a skip flag and restructures the selection validation logic to accept either a valid driver selection or a skip command. When skipped, driver-related variables are set to null and appropriate logging messages are generated.
This commit is contained in:
rbalsleyMSFT
2025-11-19 23:58:29 -08:00
parent 44aa4d3a32
commit e076e9f4ca
@@ -1298,18 +1298,32 @@ if ($null -eq $DriverSourcePath) {
} }
$displayArray | Format-Table -Property Number, Type, RelativePath -AutoSize $displayArray | Format-Table -Property Number, Type, RelativePath -AutoSize
$DriverSelected = -1
$skipDriverInstall = $false
do { do {
try { try {
$var = $true $var = $true
[int]$DriverSelected = Read-Host 'Enter the number of the driver source to install' [int]$userSelection = Read-Host 'Enter the number of the driver source to install (0 to skip)'
$DriverSelected = $DriverSelected - 1 if ($userSelection -eq 0) {
$skipDriverInstall = $true
break
}
$DriverSelected = $userSelection - 1
} }
catch { catch {
Write-Host 'Input was not in correct format. Please enter a valid number.' Write-Host 'Input was not in correct format. Please enter a valid number.'
$var = $false $var = $false
} }
} until (($DriverSelected -ge 0) -and ($DriverSelected -lt $DriverSourcesCount) -and $var) } until ((($DriverSelected -ge 0 -and $DriverSelected -lt $DriverSourcesCount) -or $skipDriverInstall) -and $var)
if ($skipDriverInstall) {
$DriverSourcePath = $null
$DriverSourceType = $null
$selectedRelativePath = $null
WriteLog 'User chose to skip driver installation.'
Write-Host "`nDriver installation was skipped."
}
else {
$DriverSourcePath = $DriverSources[$DriverSelected].Path $DriverSourcePath = $DriverSources[$DriverSelected].Path
$DriverSourceType = $DriverSources[$DriverSelected].Type $DriverSourceType = $DriverSources[$DriverSelected].Type
$selectedRelativePath = $DriverSources[$DriverSelected].RelativePath $selectedRelativePath = $DriverSources[$DriverSelected].RelativePath
@@ -1317,6 +1331,7 @@ if ($null -eq $DriverSourcePath) {
Write-Host "`nUser selected Type: $DriverSourceType, RelativePath: $selectedRelativePath" Write-Host "`nUser selected Type: $DriverSourceType, RelativePath: $selectedRelativePath"
} }
} }
}
else { else {
WriteLog "No driver WIMs or folders found in Drivers directory." WriteLog "No driver WIMs or folders found in Drivers directory."
Write-Host "No driver WIMs or folders found in Drivers directory." Write-Host "No driver WIMs or folders found in Drivers directory."