MSEndpointMgr / ConfigMgr

Microsoft Endpoint Configuration Manager scripts and tools
633 stars 281 forks source link

Parse error on HP ProDesk 600 G3 DM #120

Closed simulacra75 closed 5 years ago

simulacra75 commented 5 years ago

Error message is;

Compare-BIOSVersion : Exception calling "Parse" with "1" argument(s): "Input string was not in a correct format."

If i query the SMBIOSBIOSVERSION attribute it returns, P22 Ver. 02.22

LionZum commented 5 years ago
                "*ver*" {
                    $CurrentBIOSVersion = [System.Version]::Parse(((($CurrentBIOSProperties.SMBIOSBIOSVersion).Trim($CurrentBIOSProperties.SMBIOSBIOSVersion.Split(".")[0])).TrimStart(".")).Trim())
                }

P21 Ver. 02.22 is getting trimmed to ". 02." right after the first trim

As a work around for now, I have changed $CurrentBIOSVersion = [System.Version]::Parse(((($CurrentBIOSProperties.SMBIOSBIOSVersion).Trim($CurrentBIOSProperties.SMBIOSBIOSVersion.Split(".")[0])).TrimStart(".")).Trim())

to

$CurrentBIOSVersion = [System.Version]::Parse((((($CurrentBIOSProperties.SMBIOSBIOSVersion).Trim($CurrentBIOSProperties.SMBIOSBIOSVersion.Split(".")[0])).TrimStart(".")).Trim())+($CurrentBIOSProperties.SMBIOSBIOSVersion.Split(".")[2]))

NickolajA commented 5 years ago

You're right, it does. But your code won't work for the latest BIOS versioning standard. Here's an example:

$CurrentBIOSVersion = "P21 Ver. 02.22"
$CurrentBIOSVersion = "Q71 Ver. 01.06.03"

# Detect new versus old BIOS formats
switch -wildcard ($($CurrentBIOSVersion)) {
    "*ver*" {
        $CurrentBIOSVersion1 = [System.Version]::Parse(((($CurrentBIOSVersion).Trim($CurrentBIOSVersion.Split(".")[0])).TrimStart(".")).Trim())
        $CurrentBIOSVersion2 = [System.Version]::Parse((((($CurrentBIOSVersion).Trim($CurrentBIOSVersion.Split(".")[0])).TrimStart(".")).Trim())+($CurrentBIOSVersion.Split(".")[2]))
    }
    default {
        $CurrentBIOSVersion1 = "$($CurrentBIOSProperties.SystemBiosMajorVersion).$($CurrentBIOSProperties.SystemBiosMinorVersion)"
    }
}
$CurrentBIOSVersion1
$CurrentBIOSVersion2

We'll look into this and see if we can come up with a better solution that works in both situations.

NickolajA commented 5 years ago

I believe this code should work for both scenarios:

($CurrentBIOSVersion).TrimStart($CurrentBIOSVersion.Split(".")[0]).TrimStart(".").Trim()

NickolajA commented 5 years ago

It's been changed in 2.0.8 of the script, could you please verify if it works? Thanks.

LionZum commented 5 years ago

I’ll give it a whirl tomorrow at work and let you know.

On May 1, 2019, at 5:07 PM, Nickolaj Andersen notifications@github.com wrote:

It's been changed in 2.0.8 of the script, could you please verify if it works? Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Wraith4260 commented 5 years ago

Still getting this in 2.0.9.

image

NickolajA commented 5 years ago

Ok that's can easily be explained since your model contains chars after the version number and not only before. What model is that from?

Wraith4260 commented 5 years ago

This particular one is a Hewlett-Packard ProDesk 600 G4 Small Form Factor PC (Models included:83ee).

NickolajA commented 5 years ago

This should now be fixed in 2.1.0, could you please give it a try?

Wraith4260 commented 5 years ago

Tried with 2.1.0 on the 600 G4 a few minutes ago and it bombed. SMSTS.log indicates the error is the same but on line 549 now.

NickolajA commented 5 years ago

What if you run the following in PowerShell on that model:

$CurrentBIOSVersion = Get-WmiObject -Class Win32_BIOS | Select-Object -ExpandProperty SMBIOSBIOSVersion
[System.Version]::Parse(($CurrentBIOSVersion).TrimStart($CurrentBIOSVersion.Split(".")[0]).TrimStart(".").Trim().Split(" ")[0])
Wraith4260 commented 5 years ago

That returns the following: mbm

NickolajA commented 5 years ago

Is this on another machine? You had 02.06.03 previously in your screenshot. Could you extract the SMBIOSBIOSVersion property value please. Also, what if you run main part of the trimming itself, like the following:

$CurrentBIOSProperties = (Get-WmiObject -Class Win32_BIOS | Select-Object -Property *)

# Detect new versus old BIOS formats
switch -wildcard ($($CurrentBIOSProperties.SMBIOSBIOSVersion)) {
    "*ver*" {
        if ($CurrentBIOSProperties.SMBIOSBIOSVersion -match '.F.\d+$') {
            $CurrentBIOSVersion = ($CurrentBIOSProperties.SMBIOSBIOSVersion -split "Ver.")[1].Trim()
            $BIOSVersionParseable = $false
        }
        else {
            $CurrentBIOSVersion = [System.Version]::Parse(($CurrentBIOSProperties.SMBIOSBIOSVersion).TrimStart($CurrentBIOSProperties.SMBIOSBIOSVersion.Split(".")[0]).TrimStart(".").Trim().Split(" ")[0])
            $BIOSVersionParseable = $true
        }
    }
    default {
        $CurrentBIOSVersion = "$($CurrentBIOSProperties.SystemBiosMajorVersion).$($CurrentBIOSProperties.SystemBiosMinorVersion)"
        $BIOSVersionParseable = $true
    }
}
$CurrentBIOSVersion

What do you get?

Wraith4260 commented 5 years ago

This is the same machine. You bring up an interesting point, though.

The error in smsts.log references "02.06.03 A 1" I believe that is the available BIOS version.

The ApplyBIOSPackage.log lists the following for version matching: "Current BIOS version determined as: Q07 Ver. 02.02.04" (At the top of the log) "Current BIOS release detected as 2.2.4" (Bottom of the log) "Available BIOS release detected as 02.06.03 A 1." (Bottom of the log)

I ran the code snippet as well as got the SMBIOSBIOSVersion for you here: image

NickolajA commented 5 years ago

Ah it's the available version from the BIOS package properties, that makes sense it's just another part of the code that needs to be trimmed then.

NickolajA commented 5 years ago

Updated 2.1.0 with a small fix, please try again.

Wraith4260 commented 5 years ago

Detection seems to be working now and proceeded to set NewBIOSAvailable = true and selected the correct package ID. However, BIOS didn't flash during the TS. It appears to have used the HPFirmwareUpdRec method but didn't flash after rebooting. HPFlashBIOSUpdate.log just says 260 but I can't seem to find a list of HP BIOS exit/return codes anywhere so I'm not sure what that means. I am also, unfortunately, not as familiar with the HP BIOS/Driver realm as I am with Dell.

On the other hand I did find something odd in the Invoke-HPBIOSUpdate.log. Not sure if it is trying to find the BIOS package in the actual Invoke-HPBIOSPackage directory. I have each Invoke script for manufacturer separated out into individual packages (separate from the Invoke-CMDownloadBIOSPackage.ps1 package; its easier to update them individually and not interrupt task sequences). Just worth noting, this method does work fine with Dell BIOS updates.

image

NickolajA commented 5 years ago

That's a good catch. It has been addressed in 1.0.5. Thanks