-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathUpdateDriversBIOS.ps1
More file actions
119 lines (103 loc) · 3.72 KB
/
UpdateDriversBIOS.ps1
File metadata and controls
119 lines (103 loc) · 3.72 KB
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
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.99
Created on: 1/29/2016 2:59 PM
Created by: Mick Pletcher
Filename: UpdateDriversBIOS.ps1
===========================================================================
.DESCRIPTION
Uses Dell Command | Update to update all drivers and BIOS versions.
#>
Function Set-ConsoleTitle {
Param ([String]$Title)
$host.ui.RawUI.WindowTitle = $Title
}
Function Get-Architecture {
#Declare Local Variables
Set-Variable -Name Architecture -Scope Local -Force
$Architecture = Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture
$Architecture = $Global:Architecture.OSArchitecture
#Returns 32-bit or 64-bit
Return $Architecture
#Cleanup Local Variables
Remove-Variable -Name Architecture -Scope Local -Force
}
Function Install-Updates {
Param ([String]$DisplayName,
[String]$Executable,
[String]$Switches)
#Declare Local Variables
Set-Variable -Name ErrCode -Scope Local -Force
Write-Host "Install"$DisplayName"....." -NoNewline
If ((Test-Path $Executable) -eq $true) {
$ErrCode = (Start-Process -FilePath $Executable -ArgumentList $Switches -Wait -Passthru).ExitCode
} else {
$ErrCode = 1
}
If (($ErrCode -eq 0) -or ($ErrCode -eq 1) -or ($ErrCode -eq 3010)) {
Write-Host "Success" -ForegroundColor Yellow
} else {
Write-Host "Failed with error code "$ErrCode -ForegroundColor Red
}
#Cleanup Local Variables
Remove-Variable -Name ErrCode -Scope Local -Force
}
Function CCTKSetting {
param ($Name,
$Option,
$Setting,
$Drives,
$Architecture)
#Declare Local Variables
Set-Variable -Name Argument -Scope Local -Force
Set-Variable -Name ErrCode -Scope Local -Force
Set-Variable -Name EXE -Scope Local -Force
If ($Architecture -eq "32-bit") {
$EXE = $Env:PROGRAMFILES + "\Dell\Command Configure\X86\cctk.exe"
} else {
$EXE = ${env:ProgramFiles(x86)} + "\Dell\Command Configure\X86_64\cctk.exe"
}
If ($Option -ne "bootorder") {
$Argument = "--" + $Option + "=" + $Setting
} else {
$Argument = "bootorder" + [char]32 + "--" + $Setting + "=" + $Drives
}
Write-Host $Name"....." -NoNewline
If ((Test-Path $EXE) -eq $true) {
$ErrCode = (Start-Process -FilePath $EXE -ArgumentList $Argument -Wait -Passthru).ExitCode
} else {
$ErrCode = 1
}
If (($ErrCode -eq 0) -or ($ErrCode -eq 240) -or ($ErrCode -eq 241)) {
If ($Drives -eq "") {
Write-Host $Setting -ForegroundColor Yellow
} else {
Write-Host $Drives -ForegroundColor Yellow
}
} elseIf ($ErrCode -eq 119) {
Write-Host "Unavailable" -ForegroundColor Green
} else {
Write-Host "Failed with error code "$ErrCode -ForegroundColor Red
}
#Cleanup Local Variables
Remove-Variable -Name Argument -Scope Local -Force
Remove-Variable -Name ErrCode -Scope Local -Force
Remove-Variable -Name EXE -Scope Local -Force
}
#Declare Local Variables
Set-Variable -Name Architecture -Scope Local -Force
Set-Variable -Name EXE -Scope Local -Force
cls
Set-ConsoleTitle -Title "Dell Client Update"
$Architecture = Get-Architecture
CCTKSetting -Name "Disable BIOS Password" -Option "valsetuppwd" -Setting "<BIOS Password> --setuppwd=" -Drives "" -Architecture $Architecture
If ($Architecture -eq "32-bit") {
$EXE = $Env:PROGRAMFILES + "\Dell\CommandUpdate\dcu-cli.exe"
} else {
$EXE = ${env:ProgramFiles(x86)} + "\Dell\CommandUpdate\dcu-cli.exe"
}
Install-Updates -DisplayName "Update All Hardware Components" -Executable $EXE -Switches " "
#Cleanup Local Variables
Remove-Variable -Name Architecture -Scope Local -Force
Remove-Variable -Name EXE -Scope Local -Force