mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Improve driver injection logic and user feedback
Enhances the driver mapping logic to ensure JSON files with a single entry are handled correctly. The model matching is now more flexible, allowing for partial matches in either direction between the system's reported model and the mapping file. Adds a user-facing message to indicate that the driver injection process may take a significant amount of time, preventing confusion about the script stalling.
This commit is contained in:
@@ -545,14 +545,15 @@ if (Test-Path -Path $driverMappingPath -PathType Leaf) {
|
|||||||
}
|
}
|
||||||
WriteLog "Detected System: Manufacturer='$systemManufacturer', Model='$systemModel'"
|
WriteLog "Detected System: Manufacturer='$systemManufacturer', Model='$systemModel'"
|
||||||
|
|
||||||
# Load and parse the mapping file
|
# Load and parse the mapping file, ensuring it's always an array
|
||||||
$driverMappings = Get-Content -Path $driverMappingPath -Raw | ConvertFrom-Json
|
$driverMappings = @(Get-Content -Path $driverMappingPath -Raw | ConvertFrom-Json -ErrorAction SilentlyContinue)
|
||||||
|
|
||||||
# Find all matching rules and select the most specific one
|
# Find all matching rules and select the most specific one
|
||||||
$matchingRules = @()
|
$matchingRules = @()
|
||||||
foreach ($rule in $driverMappings) {
|
foreach ($rule in $driverMappings) {
|
||||||
# Use -like for wildcard matching
|
# Use -like for wildcard matching.
|
||||||
if ($systemManufacturer -like "$($rule.Manufacturer)*" -and $systemModel -like "$($rule.Model)*") {
|
# This checks if the system model starts with the rule model, or vice-versa, for flexibility.
|
||||||
|
if ($systemManufacturer -like "$($rule.Manufacturer)*" -and ($systemModel -like "$($rule.Model)*" -or $rule.Model -like "$systemModel*")) {
|
||||||
$matchingRules += $rule
|
$matchingRules += $rule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -865,6 +866,7 @@ if ($null -ne $DriverSourcePath) {
|
|||||||
|
|
||||||
WriteLog "Injecting drivers from $TempDriverDir"
|
WriteLog "Injecting drivers from $TempDriverDir"
|
||||||
Write-Host "Injecting drivers from $TempDriverDir"
|
Write-Host "Injecting drivers from $TempDriverDir"
|
||||||
|
Write-Host "This may take a while, please be patient."
|
||||||
Invoke-Process dism.exe "/image:W:\ /Add-Driver /Driver:""$TempDriverDir"" /Recurse"
|
Invoke-Process dism.exe "/image:W:\ /Add-Driver /Driver:""$TempDriverDir"" /Recurse"
|
||||||
WriteLog "Driver injection from WIM succeeded."
|
WriteLog "Driver injection from WIM succeeded."
|
||||||
Write-Host "Driver injection from WIM succeeded."
|
Write-Host "Driver injection from WIM succeeded."
|
||||||
|
|||||||
Reference in New Issue
Block a user