Refines driver mapping logic and adds diagnostic logging

Improves JSON parsing of the driver mapping file to handle different file structures more reliably.

Adds logging to show all potential driver mapping rules that match the current system, making it easier to diagnose rule selection.
This commit is contained in:
rbalsleyMSFT
2025-08-06 17:46:13 -07:00
parent 357261ec73
commit 6f98473009
@@ -545,7 +545,7 @@ 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, ensuring it's always an array # Load and parse the mapping file, ensuring it's always an array
$driverMappings = @(Get-Content -Path $driverMappingPath -Raw | ConvertFrom-Json -ErrorAction SilentlyContinue) $driverMappings = Get-Content -Path $driverMappingPath | Out-String | 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 = @()
@@ -553,6 +553,7 @@ if (Test-Path -Path $driverMappingPath -PathType Leaf) {
# Use -like for wildcard matching. # Use -like for wildcard matching.
# This checks if the system model starts with the rule model, or vice-versa, for flexibility. # 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*")) { if ($systemManufacturer -like "$($rule.Manufacturer)*" -and ($systemModel -like "$($rule.Model)*" -or $rule.Model -like "$systemModel*")) {
WriteLog "Match found: Manufacturer='$($rule.Manufacturer)', Model='$($rule.Model)'"
$matchingRules += $rule $matchingRules += $rule
} }
} }