MSEndpointMgr / ModernBIOSManagement

MIT License
45 stars 22 forks source link

multiple package sorting doesn't work #3

Open nodiaque opened 3 years ago

nodiaque commented 3 years ago

Hello,

When there's multiple package detected for HP or Microsoft, it's using this code to sort which one to take:


                        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

Problem is to sort, it's using "PackageCreated" which isn't part of the array. We should use the SourceDate like any other model (why the change?).

Alsso, the comment on the first sort isn't right, it says it's sorting to the latest model type match but in fact, it's sorting to the latest package match (there's a difference).

Ginolard commented 3 years ago

See my post about the same issue. I have found the issue and it's an easy fix