Open brinkenb opened 3 years ago
Got same problem with HP Bios packages.
Because some baseboards share the same SKU, it seems to detect multiple packages. It's maybe OK for drivers, but shouldn't bios look for specific model instead?
same problem with HP Bios packages
Same with any bios in fact, it doesn't check for the latest version when there's multiple
I've check the script and I understand the problem. Problem is here:
$PackageList = $PackageList | Sort-Object -Property SourceDate -Descending | Select-Object -First 1
}
if ($PackageList.Count -eq 1
Problem is after the select-object, the array doesn't exist anymore thus .count is null. I myself changed it to:
if ($PackageList.Count -lt 2 -and $PackageList[0] -ne $null) {
I'm still in the testing phase to see if that add another problem.
There's also other problem at the same place that I'll post another issue
Hello, I troubleshooting this situation about 4 hour and can verify @nodiaque issue. It's a casting error.
Have made some changes, tested and works as desired.
The fast solution is too change code from line 1168 until 1187 with this:
` if ($ComputerManufacturer -match "Dell") { $PackageList = , $($PackageList | Sort-Object -Property SourceDate -Descending | Select-Object -First 1) } elseif ($ComputerManufacturer -eq "Lenovo") { $ComputerDescription = Get-WmiObject -Class Win32_ComputerSystemProduct | Select-Object -ExpandProperty Version
$PackageList = , $($PackageList | Where-object {
($_.Name -like "*$ComputerDescription") -and ($_.Manufacturer -match $ComputerManufacturer)
} | Sort-object -Property SourceDate -Descending | Select-Object -First 1)
If ($PackageList -eq $null) {
# Fall back to select the latest model type match if no model name match is found
$PackageList = , $($PackageList | Sort-object -Property SourceDate -Descending | Select-Object -First 1)
}
} elseif ($ComputerManufacturer -match "Hewlett-Packard|HP") {
# Determine the latest BIOS package by creation date
$PackageList = , $($PackageList | Sort-Object -Property PackageCreated -Descending | Select-Object -First 1)
} elseif ($ComputerManufacturer -match "Microsoft") {
$PackageList = , $($PackageList | Sort-Object -Property PackageCreated -Descending | Select-Object -First 1)
}
`
Hope it's help you all.
EDIT: I make a rull request #4
Writing to confirm that the amendment that @mstraessner suggested is currently working for HP systems. I have not had the chance to test this with other manufacturers.
I had to do multiple additional changes to get it to work with Lenovo.
`
if ($ComputerManufacturer -match "Dell") {
[Array]$PackageList = , $($PackageList | Sort-Object -Property SourceDate -Descending | Select-Object -First 1)
} elseif ($ComputerManufacturer -eq "Lenovo") {
$ComputerDescription = Get-WmiObject -Class Win32_ComputerSystemProduct | Select-Object -ExpandProperty Version
# Attempt to find exact model match for Lenovo models which overlap model types
[Array]$PackageListExactModelMatch = , $($PackageList | Where-Object {($_.Name -like "*$ComputerDescription") -and ($_.Manufacturer -match $ComputerManufacturer)} | Sort-Object -Property SourceDate -Descending | Select-Object -First 1)
If ($PackageListExactModelMatch[0] -eq $null) {
# Fall back to select the latest model type match if no model name match is found
[Array]$PackageList = , $($PackageList | Sort-Object -Property SourceDate -Descending | Select-Object -First 1)
} elseif ($PackageListExactModelMatch[0]) {
# If match is found update Packagelist with correct model
[Array]$PackageList = $PackageListExactModelMatch
}
} elseif ($ComputerManufacturer -match "Hewlett-Packard|HP") {
# Determine the latest BIOS package by creation date
[Array]$PackageList = , $($PackageList | Sort-Object -Property PackageCreated -Descending | Select-Object -First 1)
} elseif ($ComputerManufacturer -match "Microsoft") {
[Array]$PackageList = , $($PackageList | Sort-Object -Property PackageCreated -Descending | Select-Object -First 1)}
`
And changed this:
} elseif ($ComputerManufacturer -match "Lenovo") { Compare-BIOSVersion -AvailableBIOSVersion $PackageList[0].Version -AvailableBIOSReleaseDate $(($PackageList[0].PackageDescription).Split(":")[2]).Trimend(")") -ComputerManufacturer $ComputerManufacturer }
To this:
} elseif ($ComputerManufacturer -match "Lenovo") { Compare-BIOSVersion -AvailableBIOSVersion $PackageList[0].Version -AvailableBIOSReleaseDate $(($PackageList[0].Description).Split(":")[2]).Trimend(")") -ComputerManufacturer $ComputerManufacturer }
I got it to work with Lenovo ThinkCentre series after applying the fixes from @HermanGB - thanks everyone
If there are multiple BIOS packages available for a single hardware model in my site, the script fails when trying to determine which BIOS package to use. The final line in the log file is 'Unable to determine a matching BIOS package from list since an unsupported count was returned from package list, bailing out.' I'm attaching a screenshot from the log file, thanks!