Adds SystemId support for HP driver management

Enhances HP driver handling to properly track and display SystemId alongside ProductName throughout the driver workflow.

Parses SystemId from HP PlatformList.xml and creates unique entries per ProductName/SystemId combination to avoid conflicts when multiple models share the same product name but different system identifiers.

Updates driver lookup and metadata preservation to include SystemId, MachineType, and ProductName fields across download tasks and result processing, ensuring this information persists through JSON import/export operations.

Improves display name generation to show "ProductName (SystemId)" format for HP models when both values are available, providing clearer model identification in the UI and configuration files.

Standardizes driver metadata handling by replacing simple Make lookups with comprehensive driver metadata lookups that preserve all relevant fields for Dell, HP, and Lenovo vendors.
This commit is contained in:
rbalsleyMSFT
2025-11-14 19:48:22 -08:00
parent 89601efde0
commit de80ac551b
4 changed files with 270 additions and 60 deletions
+44 -12
View File
@@ -4929,9 +4929,27 @@ if ($driversJsonPath -and (Test-Path $driversJsonPath) -and ($InstallDrivers -or
} }
} }
'HP' { 'HP' {
$systemId = if ($modelEntry.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($modelEntry.SystemId)) { $modelEntry.SystemId.Trim() } else { $null }
$baseName = if ($modelEntry.PSObject.Properties['ProductName'] -and -not [string]::IsNullOrWhiteSpace($modelEntry.ProductName)) { $modelEntry.ProductName } else { $modelName }
if ($modelName -match '(.+?)\s*\((.+?)\)$') {
if ([string]::IsNullOrWhiteSpace($baseName)) { $baseName = $matches[1].Trim() }
if ([string]::IsNullOrWhiteSpace($systemId)) { $systemId = $matches[2].Trim() }
}
if ($baseName -match '(.+?)\s*\((.+?)\)$') {
$baseName = $matches[1].Trim()
if ([string]::IsNullOrWhiteSpace($systemId)) { $systemId = $matches[2].Trim() }
}
if ([string]::IsNullOrWhiteSpace($baseName)) { $baseName = $modelName }
$displayModel = if ([string]::IsNullOrWhiteSpace($systemId)) { $baseName.Trim() } else { "$($baseName.Trim()) ($($systemId.Trim()))" }
$driverItem = [PSCustomObject]@{ $driverItem = [PSCustomObject]@{
Make = $makeName Make = $makeName
Model = $modelName Model = $displayModel
}
if (-not [string]::IsNullOrWhiteSpace($baseName)) {
$driverItem | Add-Member -NotePropertyName ProductName -NotePropertyValue $baseName.Trim()
}
if (-not [string]::IsNullOrWhiteSpace($systemId)) {
$driverItem | Add-Member -NotePropertyName SystemId -NotePropertyValue $systemId
} }
} }
'Lenovo' { 'Lenovo' {
@@ -5012,9 +5030,13 @@ if ($driversJsonPath -and (Test-Path $driversJsonPath) -and ($InstallDrivers -or
$failedDownloads = [System.Collections.Generic.List[PSCustomObject]]::new() $failedDownloads = [System.Collections.Generic.List[PSCustomObject]]::new()
if ($null -ne $parallelResults) { if ($null -ne $parallelResults) {
# Create a lookup table from the original items to get the 'Make' # Create a lookup table from the original items to retain full metadata for mapping.
$makeLookup = @{} $driverLookup = @{}
$driversToProcess | ForEach-Object { $makeLookup[$_.Model] = $_.Make } foreach ($driver in $driversToProcess) {
if (-not [string]::IsNullOrWhiteSpace($driver.Model)) {
$driverLookup[$driver.Model] = $driver
}
}
foreach ($result in $parallelResults) { foreach ($result in $parallelResults) {
if ($null -eq $result) { continue } if ($null -eq $result) { continue }
@@ -5055,20 +5077,30 @@ if ($driversJsonPath -and (Test-Path $driversJsonPath) -and ($InstallDrivers -or
if ($resultSuccess -and -not [string]::IsNullOrWhiteSpace($resultDriverPath)) { if ($resultSuccess -and -not [string]::IsNullOrWhiteSpace($resultDriverPath)) {
$modelKey = if (-not [string]::IsNullOrWhiteSpace($lookupModelName)) { $lookupModelName } else { 'Unknown model' } $modelKey = if (-not [string]::IsNullOrWhiteSpace($lookupModelName)) { $lookupModelName } else { 'Unknown model' }
$makeJson = $null $driverMetadata = $null
if (-not [string]::IsNullOrWhiteSpace($lookupModelName) -and $makeLookup.ContainsKey($lookupModelName)) { if (-not [string]::IsNullOrWhiteSpace($lookupModelName) -and $driverLookup.ContainsKey($lookupModelName)) {
$makeJson = $makeLookup[$lookupModelName] $driverMetadata = $driverLookup[$lookupModelName]
} }
if ($makeJson) { if ($driverMetadata) {
$successfullyDownloaded.Add([PSCustomObject]@{ $driverRecord = [PSCustomObject]@{
Make = $makeJson Make = $driverMetadata.Make
Model = $modelKey Model = $modelKey
DriverPath = $resultDriverPath DriverPath = $resultDriverPath
}) }
if ($driverMetadata.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($driverMetadata.SystemId)) {
$driverRecord | Add-Member -NotePropertyName SystemId -NotePropertyValue $driverMetadata.SystemId
}
if ($driverMetadata.PSObject.Properties['MachineType'] -and -not [string]::IsNullOrWhiteSpace($driverMetadata.MachineType)) {
$driverRecord | Add-Member -NotePropertyName MachineType -NotePropertyValue $driverMetadata.MachineType
}
if ($driverMetadata.PSObject.Properties['ProductName'] -and -not [string]::IsNullOrWhiteSpace($driverMetadata.ProductName)) {
$driverRecord | Add-Member -NotePropertyName ProductName -NotePropertyValue $driverMetadata.ProductName
}
$successfullyDownloaded.Add($driverRecord)
} }
else { else {
WriteLog "Warning: Could not find 'Make' for successful download of model '$modelKey'. Skipping from DriverMapping.json." WriteLog "Warning: Could not find driver metadata for successful download of model '$modelKey'. Skipping from DriverMapping.json."
} }
} }
else { else {
@@ -243,6 +243,55 @@ function Set-UIValue {
} }
} }
function Get-ConfigDriverBaseName {
param(
[string]$RawName
)
if ([string]::IsNullOrWhiteSpace($RawName)) {
return $RawName
}
if ($RawName -match '^(.*?)\s*\((.+)\)\s*$') {
return $matches[1].Trim()
}
return $RawName.Trim()
}
function Get-ConfigDriverDisplayName {
param(
[string]$Make,
[string]$StoredName,
[string]$ProductName,
[string]$SystemId,
[string]$MachineType
)
$baseName = if (-not [string]::IsNullOrWhiteSpace($ProductName)) { $ProductName } else { Get-ConfigDriverBaseName -RawName $StoredName }
switch ($Make) {
'Dell' {
if ([string]::IsNullOrWhiteSpace($baseName)) { $baseName = $StoredName }
if ([string]::IsNullOrWhiteSpace($SystemId)) { return $baseName }
return "{0} ({1})" -f $baseName.Trim(), $SystemId.Trim()
}
'HP' {
if ([string]::IsNullOrWhiteSpace($baseName)) { $baseName = $StoredName }
if ([string]::IsNullOrWhiteSpace($SystemId)) { return $baseName }
return "{0} ({1})" -f $baseName.Trim(), $SystemId.Trim()
}
'Lenovo' {
if ([string]::IsNullOrWhiteSpace($baseName)) { $baseName = $StoredName }
if ([string]::IsNullOrWhiteSpace($MachineType)) { return $baseName }
return "{0} ({1})" -f $baseName.Trim(), $MachineType.Trim()
}
default {
return $StoredName
}
}
}
function Invoke-LoadConfiguration { function Invoke-LoadConfiguration {
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
@@ -1056,15 +1105,28 @@ function Import-ConfigSupplementalAssets {
if ($null -eq $modelEntry -or -not ($modelEntry.PSObject.Properties['Name'])) { continue } if ($null -eq $modelEntry -or -not ($modelEntry.PSObject.Properties['Name'])) { continue }
$modelName = $modelEntry.Name $modelName = $modelEntry.Name
if ([string]::IsNullOrWhiteSpace($modelName)) { continue } if ([string]::IsNullOrWhiteSpace($modelName)) { continue }
$downloadStatus = if ($modelEntry.PSObject.Properties['DownloadStatus']) { $modelEntry.DownloadStatus } else { "" }
$linkValue = if ($modelEntry.PSObject.Properties['Link']) { $modelEntry.Link } else { $null }
$productName = if ($modelEntry.PSObject.Properties['ProductName']) { $modelEntry.ProductName } else { $null }
$machineType = if ($modelEntry.PSObject.Properties['MachineType']) { $modelEntry.MachineType } else { $null }
$systemId = if ($modelEntry.PSObject.Properties['SystemId']) { $modelEntry.SystemId } else { $null }
$idValue = if ($modelEntry.PSObject.Properties['Id']) { $modelEntry.Id } else { $null }
if ($null -eq $idValue -and -not [string]::IsNullOrWhiteSpace($systemId)) { $idValue = $systemId }
if ($null -eq $idValue -and -not [string]::IsNullOrWhiteSpace($machineType)) { $idValue = $machineType }
$displayModel = Get-ConfigDriverDisplayName -Make $makeName -StoredName $modelName -ProductName $productName -SystemId $systemId -MachineType $machineType
if ([string]::IsNullOrWhiteSpace($displayModel)) {
$displayModel = $modelName
}
$driverObj = [PSCustomObject]@{ $driverObj = [PSCustomObject]@{
IsSelected = $true IsSelected = $true
Make = $makeName Make = $makeName
Model = $modelName Model = $displayModel
DownloadStatus = if ($modelEntry.PSObject.Properties['DownloadStatus']) { $modelEntry.DownloadStatus } else { "" } DownloadStatus = $downloadStatus
Link = if ($modelEntry.PSObject.Properties['Link']) { $modelEntry.Link } else { $null } Link = $linkValue
ProductName = if ($modelEntry.PSObject.Properties['ProductName']) { $modelEntry.ProductName } else { $null } ProductName = $productName
MachineType = if ($modelEntry.PSObject.Properties['MachineType']) { $modelEntry.MachineType } else { $null } MachineType = $machineType
Id = if ($modelEntry.PSObject.Properties['Id']) { $modelEntry.Id } else { $null } SystemId = $systemId
Id = $idValue
} }
$State.Data.allDriverModels.Add($driverObj) $State.Data.allDriverModels.Add($driverObj)
} }
@@ -66,30 +66,45 @@ function Get-HPDriversModelList {
$settings.Async = $false # Ensure synchronous reading $settings.Async = $false # Ensure synchronous reading
$reader = [System.Xml.XmlReader]::Create($platformListXml, $settings) $reader = [System.Xml.XmlReader]::Create($platformListXml, $settings)
$uniqueModels = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase) $uniqueEntries = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)
while ($reader.Read()) { while ($reader.Read()) {
if ($reader.NodeType -eq [System.Xml.XmlNodeType]::Element -and $reader.Name -eq 'Platform') { if ($reader.NodeType -eq [System.Xml.XmlNodeType]::Element -and $reader.Name -eq 'Platform') {
# Read the inner content of the Platform node
$platformReader = $reader.ReadSubtree() $platformReader = $reader.ReadSubtree()
$platformNames = [System.Collections.Generic.List[string]]::new()
$platformSystemId = $null
while ($platformReader.Read()) { while ($platformReader.Read()) {
if ($platformReader.NodeType -eq [System.Xml.XmlNodeType]::Element -and $platformReader.Name -eq 'ProductName') { if ($platformReader.NodeType -eq [System.Xml.XmlNodeType]::Element) {
if ($platformReader.Name -eq 'ProductName') {
$modelName = $platformReader.ReadElementContentAsString() $modelName = $platformReader.ReadElementContentAsString()
if (-not [string]::IsNullOrWhiteSpace($modelName) -and $uniqueModels.Add($modelName)) { if (-not [string]::IsNullOrWhiteSpace($modelName)) {
# Add to list only if it's a new unique model $platformNames.Add($modelName.Trim())
$modelList.Add([PSCustomObject]@{ }
Make = $Make }
Model = $modelName elseif ($platformReader.Name -eq 'SystemID') {
}) $platformSystemId = $platformReader.ReadElementContentAsString().Trim()
} }
} }
} }
$platformReader.Close() $platformReader.Close()
foreach ($name in $platformNames) {
$systemIdKey = if (-not [string]::IsNullOrWhiteSpace($platformSystemId)) { $platformSystemId } else { '' }
$compositeKey = "$name|$systemIdKey"
if ($uniqueEntries.Add($compositeKey)) {
$modelList.Add([PSCustomObject]@{
Make = $Make
Model = $name
SystemId = $platformSystemId
})
}
}
} }
} }
$reader.Close() $reader.Close()
WriteLog "Successfully parsed $($modelList.Count) unique HP models from PlatformList.xml." WriteLog "Successfully parsed $($modelList.Count) HP model and SystemID combinations from PlatformList.xml."
} }
catch { catch {
@@ -97,7 +112,7 @@ function Get-HPDriversModelList {
} }
# Sort the list alphabetically by Model name before returning # Sort the list alphabetically by Model name before returning
return $modelList | Sort-Object -Property Model return $modelList | Sort-Object -Property Model, SystemId
} }
# Function to download and extract drivers for a specific HP model (Designed for ForEach-Object -Parallel) # Function to download and extract drivers for a specific HP model (Designed for ForEach-Object -Parallel)
function Save-HPDriversTask { function Save-HPDriversTask {
@@ -123,11 +138,17 @@ function Save-HPDriversTask {
[bool]$PreserveSourceOnCompress = $false [bool]$PreserveSourceOnCompress = $false
) )
$modelName = $DriverItemData.Model $displayModelName = if (-not [string]::IsNullOrWhiteSpace($DriverItemData.Model)) { $DriverItemData.Model } else { $DriverItemData.Id }
$make = $DriverItemData.Make # Should be 'HP' $make = $DriverItemData.Make # Should be 'HP'
$identifier = $modelName # Unique identifier for progress updates $productName = if ($DriverItemData.PSObject.Properties['ProductName'] -and -not [string]::IsNullOrWhiteSpace($DriverItemData.ProductName)) { $DriverItemData.ProductName } else { ConvertTo-DriverBaseName -ModelString $displayModelName }
$sanitizedModelName = ConvertTo-SafeName -Name $modelName if ([string]::IsNullOrWhiteSpace($productName)) { $productName = $displayModelName }
if ($sanitizedModelName -ne $modelName) { WriteLog "Sanitized model name: '$modelName' -> '$sanitizedModelName'" } $systemIdentifier = if ($DriverItemData.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($DriverItemData.SystemId)) { $DriverItemData.SystemId } else { $null }
if ([string]::IsNullOrWhiteSpace($displayModelName)) {
$displayModelName = if ([string]::IsNullOrWhiteSpace($systemIdentifier)) { $productName } else { Get-DriverDisplayName -BaseName $productName -Identifier $systemIdentifier }
}
$identifier = $displayModelName # Unique identifier for progress updates
$sanitizedModelName = ConvertTo-SafeName -Name $identifier
if ($sanitizedModelName -ne $identifier) { WriteLog "Sanitized model name: '$identifier' -> '$sanitizedModelName'" }
$hpDriversBaseFolder = Join-Path -Path $DriversFolder -ChildPath $make # Changed variable name for clarity $hpDriversBaseFolder = Join-Path -Path $DriversFolder -ChildPath $make # Changed variable name for clarity
$platformListXml = Join-Path -Path $hpDriversBaseFolder -ChildPath "PlatformList.xml" $platformListXml = Join-Path -Path $hpDriversBaseFolder -ChildPath "PlatformList.xml"
$modelSpecificFolder = Join-Path -Path $hpDriversBaseFolder -ChildPath $sanitizedModelName # Sanitize model name for folder path $modelSpecificFolder = Join-Path -Path $hpDriversBaseFolder -ChildPath $sanitizedModelName # Sanitize model name for folder path
@@ -135,7 +156,16 @@ function Save-HPDriversTask {
$finalStatus = "" # Initialize final status $finalStatus = "" # Initialize final status
$successState = $true # Assume success unless an operation fails $successState = $true # Assume success unless an operation fails
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Checking HP drivers for $modelName..." } if (-not (Test-Path -Path $DriversFolder -PathType Container)) {
WriteLog "Creating Drivers folder: $DriversFolder"
New-Item -Path $DriversFolder -ItemType Directory -Force | Out-Null
}
if (-not (Test-Path -Path $hpDriversBaseFolder -PathType Container)) {
WriteLog "Creating HP drivers folder: $hpDriversBaseFolder"
New-Item -Path $hpDriversBaseFolder -ItemType Directory -Force | Out-Null
}
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Checking HP drivers for $displayModelName..." }
try { try {
# Check for existing drivers # Check for existing drivers
@@ -190,13 +220,23 @@ function Save-HPDriversTask {
} }
} }
# Parse PlatformList.xml to find SystemID and OSReleaseID for the specific model # Parse the PlatformList.xml to find the SystemID based on the ProductName
WriteLog "Parsing $platformListXml for model '$modelName' details..." WriteLog "Parsing $platformListXml for model '$displayModelName' (SystemID: $systemIdentifier) details..."
[xml]$platformListContent = Get-Content -Path $platformListXml -Raw -Encoding UTF8 -ErrorAction Stop [xml]$platformListContent = Get-Content -Path $platformListXml -Raw -Encoding UTF8 -ErrorAction Stop
$platformNode = $platformListContent.ImagePal.Platform | Where-Object { $_.ProductName.'#text' -match "^$([regex]::Escape($modelName))$" } | Select-Object -First 1 $platformNode = $null
if (-not [string]::IsNullOrWhiteSpace($systemIdentifier)) {
$platformNode = $platformListContent.ImagePal.Platform | Where-Object { $_.SystemID -eq $systemIdentifier } | Select-Object -First 1
if ($null -eq $platformNode) {
WriteLog "SystemID '$systemIdentifier' not found in PlatformList.xml. Falling back to ProductName search."
}
}
if ($null -eq $platformNode) {
$searchName = if (-not [string]::IsNullOrWhiteSpace($productName)) { $productName } else { $displayModelName }
$platformNode = $platformListContent.ImagePal.Platform | Where-Object { $_.ProductName.'#text' -match "^$([regex]::Escape($searchName))$" } | Select-Object -First 1
}
if ($null -eq $platformNode) { if ($null -eq $platformNode) {
throw "Model '$modelName' not found in PlatformList.xml." throw "Model '$displayModelName' (SystemID: $systemIdentifier) not found in PlatformList.xml."
} }
$systemID = $platformNode.SystemID $systemID = $platformNode.SystemID
@@ -289,11 +329,11 @@ function Save-HPDriversTask {
} }
$availableVersionsString = ($allAvailableVersions | Select-Object -Unique) -join ', ' $availableVersionsString = ($allAvailableVersions | Select-Object -Unique) -join ', '
if ([string]::IsNullOrWhiteSpace($availableVersionsString)) { $availableVersionsString = "None" } if ([string]::IsNullOrWhiteSpace($availableVersionsString)) { $availableVersionsString = "None" }
throw "Could not find any suitable OS driver pack for model '$modelName' matching requested or fallback versions (Win$($WindowsRelease) $WindowsVersion). Available: $availableVersionsString" throw "Could not find any suitable OS driver pack for model '$displayModelName' matching requested or fallback versions (Win$($WindowsRelease) $WindowsVersion). Available: $availableVersionsString"
} }
$osReleaseIdFileName = $selectedOSNode.OSReleaseIdFileName -replace 'H', 'h' $osReleaseIdFileName = $selectedOSNode.OSReleaseIdFileName -replace 'H', 'h'
WriteLog "Using SystemID: $systemID and OS Info: Win$($selectedOSRelease) ($($selectedOSVersion)) for '$modelName'" WriteLog "Using SystemID: $systemID and OS Info: Win$($selectedOSRelease) ($($selectedOSVersion)) for '$displayModelName'"
$archSuffix = $WindowsArch -replace "^x", "" $archSuffix = $WindowsArch -replace "^x", ""
$modelRelease = "$($systemID)_$($archSuffix)_$($selectedOSRelease).0.$($selectedOSVersion.ToLower())" $modelRelease = "$($systemID)_$($archSuffix)_$($selectedOSRelease).0.$($selectedOSVersion.ToLower())"
$driverCabUrl = "https://hpia.hpcloud.hp.com/ref/$systemID/$modelRelease.cab" $driverCabUrl = "https://hpia.hpcloud.hp.com/ref/$systemID/$modelRelease.cab"
@@ -312,7 +352,7 @@ function Save-HPDriversTask {
$updates = $driverXmlContent.ImagePal.Solutions.UpdateInfo | Where-Object { $_.Category -match '^Driver' } $updates = $driverXmlContent.ImagePal.Solutions.UpdateInfo | Where-Object { $_.Category -match '^Driver' }
$totalDrivers = ($updates | Measure-Object).Count $totalDrivers = ($updates | Measure-Object).Count
$downloadedCount = 0 $downloadedCount = 0
WriteLog "Found $totalDrivers driver updates for $modelName." WriteLog "Found $totalDrivers driver updates for $displayModelName."
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Found $totalDrivers drivers. Downloading..." } if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Found $totalDrivers drivers. Downloading..." }
if (-not (Test-Path -Path $modelSpecificFolder)) { if (-not (Test-Path -Path $modelSpecificFolder)) {
@@ -359,7 +399,7 @@ function Save-HPDriversTask {
} }
Remove-Item -Path $driverCabFile, $driverXmlFile -Force -ErrorAction SilentlyContinue Remove-Item -Path $driverCabFile, $driverXmlFile -Force -ErrorAction SilentlyContinue
WriteLog "Cleaned up driver cab and xml files for $modelName" WriteLog "Cleaned up driver cab and xml files for $displayModelName"
$finalStatus = "Completed" $finalStatus = "Completed"
if ($CompressToWim) { if ($CompressToWim) {
@@ -380,7 +420,7 @@ function Save-HPDriversTask {
$successState = $true $successState = $true
} }
catch { catch {
$errorMessage = "Error saving HP drivers for $($modelName): $($_.Exception.Message)" $errorMessage = "Error saving HP drivers for $($displayModelName): $($_.Exception.Message)"
WriteLog $errorMessage WriteLog $errorMessage
$finalStatus = "Error: $($_.Exception.Message.Split([Environment]::NewLine)[0])" $finalStatus = "Error: $($_.Exception.Message.Split([Environment]::NewLine)[0])"
$successState = $false $successState = $false
@@ -69,7 +69,16 @@ function Convert-DriverItemToJsonModel {
return $modelObject return $modelObject
} }
'HP' { 'HP' {
return @{ Name = $DriverItem.Model } $baseName = if ($DriverItem.PSObject.Properties['ProductName'] -and -not [string]::IsNullOrWhiteSpace($DriverItem.ProductName)) { $DriverItem.ProductName } else { ConvertTo-DriverBaseName -ModelString $DriverItem.Model }
if ([string]::IsNullOrWhiteSpace($baseName)) {
$baseName = $DriverItem.Model
}
$systemId = if ($DriverItem.PSObject.Properties['SystemId']) { $DriverItem.SystemId } else { $null }
$modelObject = @{ Name = $baseName.Trim() }
if (-not [string]::IsNullOrWhiteSpace($systemId)) {
$modelObject.SystemId = $systemId
}
return $modelObject
} }
'Lenovo' { 'Lenovo' {
$machineType = $DriverItem.MachineType $machineType = $DriverItem.MachineType
@@ -174,6 +183,7 @@ function ConvertTo-StandardizedDriverModel {
$link = $null $link = $null
$productName = $null $productName = $null
$machineType = $null $machineType = $null
$systemId = $null
if ($RawDriverObject.PSObject.Properties['Link']) { if ($RawDriverObject.PSObject.Properties['Link']) {
$link = $RawDriverObject.Link $link = $RawDriverObject.Link
@@ -187,6 +197,17 @@ function ConvertTo-StandardizedDriverModel {
$id = $RawDriverObject.MachineType $id = $RawDriverObject.MachineType
} }
# HP specific handling
if ($Make -eq 'HP') {
$productName = if ($RawDriverObject.PSObject.Properties['ProductName'] -and -not [string]::IsNullOrWhiteSpace($RawDriverObject.ProductName)) { $RawDriverObject.ProductName } else { ConvertTo-DriverBaseName -ModelString $RawDriverObject.Model }
if ([string]::IsNullOrWhiteSpace($productName)) { $productName = $RawDriverObject.Model }
if ($RawDriverObject.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($RawDriverObject.SystemId)) {
$systemId = $RawDriverObject.SystemId
}
$modelDisplay = if ([string]::IsNullOrWhiteSpace($systemId)) { $productName } else { Get-DriverDisplayName -BaseName $productName -Identifier $systemId }
$id = if ([string]::IsNullOrWhiteSpace($systemId)) { $productName } else { $systemId }
}
# Dell-specific passthrough (needed for per-model cab workflow) # Dell-specific passthrough (needed for per-model cab workflow)
$dellBrand = $null $dellBrand = $null
$dellModelNumber = $null $dellModelNumber = $null
@@ -221,6 +242,9 @@ function ConvertTo-StandardizedDriverModel {
$output | Add-Member -NotePropertyName SystemId -NotePropertyValue $dellSystemId $output | Add-Member -NotePropertyName SystemId -NotePropertyValue $dellSystemId
$output | Add-Member -NotePropertyName CabUrl -NotePropertyValue $dellCabUrl $output | Add-Member -NotePropertyName CabUrl -NotePropertyValue $dellCabUrl
} }
elseif ($Make -eq 'HP' -and -not [string]::IsNullOrWhiteSpace($systemId)) {
$output | Add-Member -NotePropertyName SystemId -NotePropertyValue $systemId
}
return $output return $output
} }
@@ -432,6 +456,28 @@ function Import-DriversJson {
$importedModelObject | Add-Member -NotePropertyName SystemId -NotePropertyValue $systemId $importedModelObject | Add-Member -NotePropertyName SystemId -NotePropertyValue $systemId
} }
} }
'HP' {
$baseName = ConvertTo-DriverBaseName -ModelString $normalizedName
if ([string]::IsNullOrWhiteSpace($baseName)) { $baseName = $normalizedName }
$systemId = if ($importedModelObject.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($importedModelObject.SystemId)) { $importedModelObject.SystemId } else { $null }
if ([string]::IsNullOrWhiteSpace($systemId) -and $normalizedName -match '(.+?)\s*\((.+?)\)$') {
if ([string]::IsNullOrWhiteSpace($baseName)) { $baseName = $matches[1].Trim() }
$systemId = $matches[2].Trim()
}
$normalizedName = if ([string]::IsNullOrWhiteSpace($systemId)) { $baseName.Trim() } else { Get-DriverDisplayName -BaseName $baseName -Identifier $systemId }
if ($importedModelObject.PSObject.Properties['ProductName']) {
$importedModelObject.ProductName = $baseName
}
else {
$importedModelObject | Add-Member -NotePropertyName ProductName -NotePropertyValue $baseName
}
if ($importedModelObject.PSObject.Properties['SystemId']) {
$importedModelObject.SystemId = $systemId
}
else {
$importedModelObject | Add-Member -NotePropertyName SystemId -NotePropertyValue $systemId
}
}
default { default {
$normalizedName = $normalizedName.Trim() $normalizedName = $normalizedName.Trim()
} }
@@ -454,6 +500,7 @@ function Import-DriversJson {
if ($null -ne $existingModel) { if ($null -ne $existingModel) {
$existingModel.IsSelected = $true $existingModel.IsSelected = $true
$existingModel.DownloadStatus = "Imported" $existingModel.DownloadStatus = "Imported"
$existingModel.Model = $importedModelNameFromObject
if ($makeName -eq 'Microsoft' -and $importedModelObject.PSObject.Properties['Link']) { if ($makeName -eq 'Microsoft' -and $importedModelObject.PSObject.Properties['Link']) {
if ($existingModel.Link -ne $importedModelObject.Link) { if ($existingModel.Link -ne $importedModelObject.Link) {
@@ -491,6 +538,13 @@ function Import-DriversJson {
} }
} }
} }
elseif ($makeName -eq 'HP') {
$importedProductName = if ($importedModelObject.PSObject.Properties['ProductName'] -and -not [string]::IsNullOrWhiteSpace($importedModelObject.ProductName)) { $importedModelObject.ProductName } else { ConvertTo-DriverBaseName -ModelString $importedModelNameFromObject }
if ([string]::IsNullOrWhiteSpace($importedProductName)) { $importedProductName = $importedModelNameFromObject }
if ($importedModelObject.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($importedModelObject.SystemId)) {
$importedId = $importedModelObject.SystemId
}
}
$existingModelsUpdated++ $existingModelsUpdated++
WriteLog "Import-DriversJson: Marked existing model '$($existingModel.Make) - $($existingModel.Model)' as imported." WriteLog "Import-DriversJson: Marked existing model '$($existingModel.Make) - $($existingModel.Model)' as imported."
@@ -548,6 +602,11 @@ function Import-DriversJson {
$newDriverModel | Add-Member -NotePropertyName CabUrl -NotePropertyValue $importedModelObject.CabUrl $newDriverModel | Add-Member -NotePropertyName CabUrl -NotePropertyValue $importedModelObject.CabUrl
} }
} }
elseif ($makeName -eq 'HP') {
if ($importedModelObject.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($importedModelObject.SystemId)) {
$newDriverModel | Add-Member -NotePropertyName SystemId -NotePropertyValue $importedModelObject.SystemId
}
}
$State.Data.allDriverModels.Add($newDriverModel) $State.Data.allDriverModels.Add($newDriverModel)
$newModelsAdded++ $newModelsAdded++
WriteLog "Import-DriversJson: Added new model '$($newDriverModel.Make) - $($newDriverModel.Model)' from import. ID: $($newDriverModel.Id), Link: $($newDriverModel.Link)" WriteLog "Import-DriversJson: Added new model '$($newDriverModel.Make) - $($newDriverModel.Model)' from import. ID: $($newDriverModel.Id), Link: $($newDriverModel.Link)"
@@ -819,10 +878,13 @@ function Invoke-DownloadSelectedDrivers {
# Check the results from the parallel processing tasks # Check the results from the parallel processing tasks
if ($null -ne $parallelResults) { if ($null -ne $parallelResults) {
# Create a lookup from the original selected drivers to get the 'Make' property, # Create a lookup from the original selected drivers to retain full metadata for mapping.
# as the result object might only have 'Identifier' or 'Model'. $driverLookup = @{}
$makeLookup = @{} foreach ($driver in $selectedDrivers) {
$selectedDrivers | ForEach-Object { $makeLookup[$_.Model] = $_.Make } if (-not [string]::IsNullOrWhiteSpace($driver.Model)) {
$driverLookup[$driver.Model] = $driver
}
}
# Filter for objects that could be results, avoiding stray log strings # Filter for objects that could be results, avoiding stray log strings
foreach ($result in ($parallelResults | Where-Object { $_ -is [hashtable] })) { foreach ($result in ($parallelResults | Where-Object { $_ -is [hashtable] })) {
@@ -856,16 +918,30 @@ function Invoke-DownloadSelectedDrivers {
} }
elseif (-not [string]::IsNullOrWhiteSpace($driverPath)) { elseif (-not [string]::IsNullOrWhiteSpace($driverPath)) {
# The task was successful and returned a driver path. # The task was successful and returned a driver path.
$make = $makeLookup[$modelName] $driverMetadata = $null
if ($make) { if (-not [string]::IsNullOrWhiteSpace($modelName) -and $driverLookup.ContainsKey($modelName)) {
$successfullyDownloaded.Add([PSCustomObject]@{ $driverMetadata = $driverLookup[$modelName]
Make = $make }
if ($driverMetadata) {
$driverRecord = [PSCustomObject]@{
Make = $driverMetadata.Make
Model = $modelName Model = $modelName
DriverPath = $driverPath DriverPath = $driverPath
}) }
if ($driverMetadata.PSObject.Properties['SystemId'] -and -not [string]::IsNullOrWhiteSpace($driverMetadata.SystemId)) {
$driverRecord | Add-Member -NotePropertyName SystemId -NotePropertyValue $driverMetadata.SystemId
}
if ($driverMetadata.PSObject.Properties['MachineType'] -and -not [string]::IsNullOrWhiteSpace($driverMetadata.MachineType)) {
$driverRecord | Add-Member -NotePropertyName MachineType -NotePropertyValue $driverMetadata.MachineType
}
if ($driverMetadata.PSObject.Properties['ProductName'] -and -not [string]::IsNullOrWhiteSpace($driverMetadata.ProductName)) {
$driverRecord | Add-Member -NotePropertyName ProductName -NotePropertyValue $driverMetadata.ProductName
}
$successfullyDownloaded.Add($driverRecord)
} }
else { else {
WriteLog "Warning: Could not find 'Make' for successful download of model '$modelName'. Skipping from DriverMapping.json." WriteLog "Warning: Could not find driver metadata for successful download of model '$modelName'. Skipping from DriverMapping.json."
} }
} }
else { else {