-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdate-DCU.ps1
87 lines (68 loc) · 2.89 KB
/
Update-DCU.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
<#
Update-DCU
Update DCU client from 2.4.0 to 3.1.0
Jarred Reid - 2019
Changelog:
1.0.0 - Initial release
1.0.1 - Fixed a bug where users would be notified about updates
1.0.2 - Removed using Win32_Product, opting for Get-Package instead.
Read why here: (https://docs.microsoft.com/en-us/powershell/scripting/samples/working-with-software-installations?view=powershell-6)
1.0.3 - Fixed operands for $DCU variable
#>
### Get DCU Variable
$DCU = Get-Package | Where-Object {$_.Name -like "Dell Command | Update*"}
if($DCU.Version -eq "2.4.0" -or $DCU.Version -eq "3.0.1"){
<#
Write-Output "Older version found. Beginning uninstall process..."
try{
$DCU.Uninstall()
}
catch{
Write-Output "An error occured during the uninstall process. Please try again."
Write-Output "Error: " $_
break
}
#>
Write-Output "Older version found. Downloading DCU 3.1.0."
$DCU3 = "\\fileserver\UserShares\Dept-IT\ServiceCatalog-Technical\_Drivers-Firmware\Dell\Dell_Command_Update\Dell-Command-Update_0NJ7C_WIN_3.1.0_A00.EXE"
$DCUSettings = "\\fileserver\UserShares\Dept-IT\ServiceCatalog-Technical\_Drivers-Firmware\Dell\Dell_Command_Update\DCU-Settings.xml"
try{
Copy-Item $DCU3 -Destination "C:\Temp\DCU_Setup_3_1_0.exe"
Copy-Item $DCUSettings -Destination "C:\Temp\DCU-Settings.xml"
}
catch{
Write-Output "A connection error occured. The file could not be downloaded."
Write-Output "Error: " $_
break
}
try{
Write-Output "Installing DCU 3.1.0..."
$installDCU = Start-Process "C:\Temp\DCU_Setup_3_1_0.exe" -ArgumentList "/s /f" -PassThru
### New technique to tell Start-Process to wait until process has ended to continue the script:
$installDCU.WaitForExit()
### Check if DCU.version matches string "3.1.0" before printing success message
$DCU = Get-Package | Where-Object {$_.Name -like "Dell Command | Update*"}
if($DCU.version -eq "3.1.0"){
Write-Output "Installation successful!"
### Import settings from XML file
Start-Process "C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe" -ArgumentList "/configure -importSettings=C:\Temp\DCU-Settings.xml"
Write-Output "Settings imported."
### Clean up, clean up, everybody do your share. Leaving XML file because the settings won't import successfully until the next launch of DCU
Remove-Item "C:\Temp\DCU_Setup_3_1_0.exe"
break
}
}
catch{
Write-Output "An error occurred while installing."
Write-Output "Error: " $_
break
}
}
if($DCU.Version -eq "3.1.0"){
Write-Output "Latest version installed."
break
}
if($DCU.Version -eq $null){
Write-Output "Dell Command Update not installed."
break
}