MSEndpointMgr / ModernBIOSManagement

MIT License
45 stars 22 forks source link

Unable to determine a matching BIOS package from list since an unsupported count was returned from package list #7

Open Ginolard opened 3 years ago

Ginolard commented 3 years ago

There seems to be a logic issue when multiple BIOS are matched using the SKU matching. For example, the BIOS for HP 830 G7, 840 G7 and HP Zbook Firefly 14 G7 are all the same SKU (8723) but we have imported all of them.

So, when installing any of those models, the script detects three "different" BIOS packages and does not know which one to select. Screenshot

UPDATE: OK, did a little digging and I know the problem. You need to strongly type $PackageList as [array] when you detect multiple package. Otherwise when you use Select-Object -First 1, it does NOT return an array and the Count property is missing.

Explanation here

So, in lines 1124-1185 you should change every

$PackageList = $PackageList | Sort-object -Property SourceDate -Descending | Select-Object -First 1

to

[array]$PackageList = $PackageList | Sort-object -Property SourceDate -Descending | Select-Object -First 1

Additionally, as mentioned in another post you need to sort on SourceDate and not PackageCreated.

Jabbaxx commented 3 years ago

Thanks Ginolard. I can confirm this on Lenovo. There are several occurrences of the "$PackageList = $PackageList | *" lines where there must be added "[array]" in the beginning.

NorbertBauer commented 3 years ago

Thanks

I can confirm, but I i think the problem is the IF-Statement in line 1125: if ($PackageList.Count -ge 1) { becaue of th "-ge" it will not use the Elseif ($PackageList.Count -ge 2) from line 1164

I changed the line 1125 to if ($PackageList.Count -eq 1) { and then it worked like a charm