The age old chore of bios updating.

I have recently relised that some of laptops i have at work where extremely out of date, some by a few years. The fun part is having to update them all. So i set out to have it happen automaticly in our SCCM Task Sequences Eventually i came op with a good solution that works well but still i need to make it work better with the out put of the HP flash tool. The older computers that use the hpqflash are more tricky to get workin. usualy you will have to make the pasword file on the model you are updating for the tool accept the password. Also we had one of our 840 g3 mainboard replaced and it ended up with a slitly diffrent version of the computer model name in the wmi querys.

Set-BiosConfig.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
$ComputerInfo = Get-CimInstance Win32_ComputerSystem
$CurrentBiosVersion = (Get-CimInstance win32_bios).SMBIOSBIOSVersion

#Computers that have duplicate names in switch
#get variables put here to reduce duplication errors
$OldEliteBook840G4BIOS = @(
    "P78 Ver. 01.06"
)
$NewEliteBook840G4BIOS = "P78 Ver. 01.08"
$EliteBook840G4BIOS = "P78_0108.bin"

$OldEliteBook840G3BIOS = @(
    "N75 Ver. 01.05",
    "N75 Ver. 01.10",
    "N75 Ver. 01.13",
    "N75 Ver. 01.14",
    "N75 Ver. 01.16"
)
$NewEliteBook840G3BIOS = "N75 Ver. 01.18"
$EliteBook840G3BIOS = "N75_0118.bin"

switch -exact (($ComputerInfo).Model) {
    "HP ProBook 6570b" {
        $model = "Probook-6570b"
        $flash = "old"
        $password = "Probook-6570b\6570bpass.bin"
        $OldBIOSVer = @("68ICE Ver. F.32")
        if ($CurrentBiosVersion -like "*ICE*") {
            $BIOS = "68ICE_F68.CAB"
            $NewBIOSVer = "68ICE Ver. F.68"
        }
        elseif ($CurrentBiosVersion -like "*ICF*") {
            $BIOS = "68ICF_F68.CAB"
            $NewBIOSVer = "68ICF Ver. F.68"
        }
        Break
    }
    "HP ProBook 4330s" {
        $model = "Probook-4330s"
        $flash = "old"
        $password = "Probook-4330s\4330spass.bin"
        $BIOS = "68SRR_F.63RevA.CAB"
        $OldBIOSVer = @(
            "68SRR Ver. F.20",
            "68SRR Ver. F.27",
            "68SRR Ver. F.50",
            "68SRR Ver. F.60",
            "68SRR Ver. F.61")
        $NewBIOSVer = "68SRR Ver. F.63"
        Break
    }
    "HP Pro x2 612 G1 Tablet" {
        $model = "ProBook-x612"
        $flash = "new"
        $BIOS = "M83_0138.bin"
        $OldBIOSVer = @(
            "M83 Ver. 01.01",
            "M83 Ver. 01.31",
            "M83 Ver. 01.32",
            "M83 Ver. 01.34",
            "M83 Ver. 01.35",
            "M83 Ver. 01.36"
        )
        $NewBIOSVer = "M83 Ver. 01.38"
        Break
    }
    "HP EliteBook 840 G1" {
        $model = "EliteBook-840-G1"
        $flash = "new"
        $BIOS = "L71_0140.bin"
        $OldBIOSVer = @(
            "L71 Ver. 1.32",
            "L71 Ver. 1.39"
        )
        $NewBIOSVer = "L71 Ver. 1.40"
        Break
    }
    "HP EliteBook 840 G3" {
        $model = "EliteBook-840-G3"
        $flash = "new"
        $BIOS = $EliteBook840G3BIOS
        $OldBIOSVer = $OldEliteBook840G3BIOS
        $NewBIOSVer = $NewEliteBook840G3BIOS
        Break
    }
    "HP EliteBook 840 G3 NoteBook PC" {
        $model = "EliteBook-840-G3"
        $flash = "new"
        $BIOS = $EliteBook840G3BIOS
        $OldBIOSVer = $OldEliteBook840G3BIOS
        $NewBIOSVer = $NewEliteBook840G3BIOS
        Break
    }
    "HP EliteBook 840 G4" {
        $model = "EliteBook-840-G4"
        $flash = "new"
        $BIOS = $EliteBook840G4BIOS
        $OldBIOSVer = $OldEliteBook840G4BIOS
        $NewBIOSVer = $NewEliteBook840G4BIOS
        Break
    }
    "HP EliteBook 840 G4 NoteBook PC" {
        $model = "EliteBook-840-G4"
        $flash = "new"
        $BIOS = $EliteBook840G4BIOS
        $OldBIOSVer = $OldEliteBook840G4BIOS
        $NewBIOSVer = $NewEliteBook840G4BIOS
        Break
    }
    "HP EliteDesk 800 G1 SFF" {
        $model = "EliteDesk-800-G1-SFF"
        $flash = "old"
        $password = "EliteDesk-800-G1-SFF\800G1Pass.bin"
        $BIOS = "L01_v02.65 Rev.A.cab"
        $OldBIOSVer = @(
            "L01 Ver. 02.65"
        )
        $NewBIOSVer = "L01 Ver. 02.71"
        Break
    }
    "HP ProDesk 600 G2 SFF" {
        $model = "ProDesk-600-G2-SFF"
        $flash = "new"
        $BIOS = "N02_0222.bin"
        $OldBIOSVer = @(
            "N02 Ver. 02.17"
        )
        $NewBIOSVer = "N02 Ver. 02.22"
        Break
    }
    "HP EliteBook Revolve 810 G3" {
        $model = "EliteBook-Revolve-810-G3"
        $flash = "new"
        $BIOS = "M86_0111.bin"
        $OldBIOSVer = @(
            "M86 Ver. 01.02",
            "M86 Ver. 01.03",
            "M86 Ver. 01.04",
            "M86 Ver. 01.05",
            "M86 Ver. 01.07",
            "M86 Ver. 01.08",
            "M86 Ver. 01.09"
        )
        $NewBIOSVer = "M86 Ver. 01.11"
        Break
    }
    "HP EliteOne 800 G2 23-in Non-Touch AiO" {
        $model = "EliteOne-800-G2-AiO"
        $flash = "new"
        $BIOS = "N11_0222.bin"
        $OldBIOSVer = @(
            "N11 Ver. 02.17"
        )
        $NewBIOSVer = "N11 Ver. 02.22"
        Break
    }
    Default {Write-Host "Not A Model That I Know. My model name is `"$(($ComputerInfo).Model)`""; Start-Sleep -Seconds 30; Exit}
}

Write-Output "Setting Bios For a `"$(($ComputerInfo).Model)`""
Write-Output "Model: $model"
Write-Output "BIOS FILE: $BIOS"
Write-Output "Old BIOS Versions: $OldBIOSVer"
Write-Output "New BIOS Version: $NewBIOSVer"
Write-Output "Current BIOS Version: $CurrentBiosVersion"

$tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment

if (($model -eq $null) -or ($BIOS -eq $null) -or ($OldBIOSVer -eq $null) -or ($NewBIOSVer -eq $null)) {
    Write-Host "I Do NOT have a BIOS Update Config for this machine."
    Start-Sleep -Seconds 10
    $LASTEXITCODE = 0
    Exit $LASTEXITCODE
}

if ($CurrentBiosVersion -eq $NewBIOSVer) {
    Write-Output "Bios Is Already Current"
    Start-Sleep -Seconds 10
    Exit 0
}
elseif ($OldBIOSVer -contains $CurrentBiosVersion) {
    if ($flash -eq "old") {
        try {
            Write-Output "Updating BIOS From `"$CurrentBiosVersion`" To `"$NewBIOSVer`" With Legacy Tool"
            Start-Process "$PSScriptRoot\HP\HPQFlash64.exe" -ArgumentList "-s -p`"$PSScriptRoot\HP\$password`" -f`"$PSScriptRoot\HP\$model\$bios`" -a" -Wait -ErrorAction Stop -WarningAction Stop -PassThru -NoNewWindow -ErrorVariable $errormessage
            Get-Content -Path $PSScriptRoot\HP\hpqFlash.log
            Start-Sleep 10
            $tsenv.Value("BIOSUpdateReboot") = "true"
            EXIT 3010
        }
        catch {
            Write-Output "i had a issue flashing the bios with legacy tool error code: $LASTEXITCODE"
            Write-Output "$errormessage"
            Start-Sleep -Seconds 30
            EXIT $LASTEXITCODE
        }
    }
    else {
        try {
            Write-Output "Updating BIOS From `"$CurrentBiosVersion`" To `"$NewBIOSVer`" With Modern Tool"
            Start-Process "$PSScriptRoot\HP\HPBIOSUPDREC64.exe" -ArgumentList "-s -r -p$PSScriptRoot\HP\password.bin -f$PSScriptRoot\HP\$model\$bios -a" -Wait -ErrorAction Stop -WarningAction Stop
            Start-Sleep 10
            $tsenv.Value("BIOSUpdateReboot") = "true"
            EXIT 3010
        }
        catch {
            Write-Output "i had a issue flashing the bios with modern tool error code: $LASTEXITCODE"
            Start-Sleep -Seconds 30
            EXIT $LASTEXITCODE
        }
    }

}
else {
    Write-Output "This BIOS is not in the list that i can flash"
    Start-Sleep -Seconds 30
    Exit $LASTEXITCODE
}