This script can be used to install Dell Command Upgrade. If it is already installed, the version available in the installer will be compared with the version currently installed; if needed it will then be upgraded.
# Install Dell Command | Update to run driver/firmware updates for Dell PC's
#Requires -RunAsAdministrator
# The path to install from
$installer = '\\fileserver\Software\Dell\Dell_Command_Update.exe'
# Check the Windows OS to ensure it is a desktop OS, this does not belong on any servers
Write-Host -ForegroundColor Gray 'Validating this script is running on a Desktop version of Windows; not supported for Windows Server...'
try {
$os = Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction Stop
$osname = $os.Caption
$ostype = $os.ProductType
Write-Host -ForegroundColor Gray "Got operating system '$osname' and ProductType '$ostype'"
}
catch {
$message = $_.Exception.message
Write-Error 'Error querying the operating system that is running with CIM'
throw $message
}
if ( $ostype -ne 1 ) {
Write-Host -ForegroundColor DarkRed 'Dell Command | Update is only supported on desktop OS, it will not be installed on this edition of Windows.'
exit
}
# Get the system information
Write-Host -ForegroundColor Gray 'Getting system manufacturer...'
try {
$manufacturer = (Get-CimInstance -ClassName Win32_ComputerSystem -ErrorAction Stop | Select-Object -ExpandProperty Manufacturer -ErrorAction Stop)
Write-Host -ForegroundColor Gray "Got system manufacturer: $manufacturer"
$model = (Get-CimInstance -ClassName Win32_ComputerSystem -ErrorAction Stop | Select-Object -ExpandProperty Model -ErrorAction Stop)
Write-Host -ForegroundColor Gray "Got system model: $model"
}
catch {
$message = $_.Exception.message
Write-Error 'Error querying the manufacturer/model, cannot continue without knowing if this is a Dell PC or not'
throw $message
}
# Check if this is a Dell computer
if ( $manufacturer -notlike '*Dell*') {
Write-Host -ForegroundColor DarkRed "System manufacturer ($manufacturer) does not match Dell; Dell Command will not be installed."
exit
} else {
Write-Host -ForegroundColor Green 'System manufacturer appears to be Dell; proceeding with installation/update.'
}
# Check if the model is supported
if ( $model -notlike '*OptiPlex*' -and $model -notlike '*Latitude*' -and $model -notlike '*XPS*' -and $model -notlike '*Precision*' ) {
Write-Host -ForegroundColor DarkRed 'System model is not supported; Dell Command will not be installed.'
exit
}
# Try and reach the file server - If the networking is not up yet (maybe up to a minute delay) pause the task before trying again otherwise give up
Write-Host -ForegroundColor Gray 'Validating the file server can be accessed...'
if ( Test-Connection filesrv-ceb02.internal.dreamscapenetworks.com -Quiet -Count 1 ) {
Write-Host -ForegroundColor Green 'Fileserver responds to ICMP'
} else {
Write-Host -ForegroundColor Yellow 'Fileserver does not respond to ICMP - this script will wait for 60 seconds before attempting again and then giving up'
Start-Sleep -Seconds 60
if ( Test-Connection filesrv-ceb02.internal.dreamscapenetworks.com -Quiet -Count 1 ) {
Write-Host -ForegroundColor Green 'Fileserver responds to ICMP'
} else {
Write-Host -ForegroundColor DarkRed 'Could not reach fileserver; giving up'
exit
}
}
# Validate that we can access the install file
Write-Host -ForegroundColor Gray 'Validating the installer can be accessed...'
if ( Test-Path -Path $installer ) {
Write-Host -ForegroundColor Gray 'Installer accessible'
} else {
Write-Host -ForegroundColor DarkRed 'Installer could not be accessed, please set the correct path.'
exit
}
# Get the version of the installer file
Write-Host -ForegroundColor Gray 'Getting available installer version...'
try {
$installerversion = (Get-Item $installer).VersionInfo.ProductVersion
} catch {
$message = $_.Exception.message
Write-Error 'Exception getting file version:'
throw $message
}
if ( [string]::IsNullOrEmpty($installerversion) ) {
Write-Host -ForegroundColor DarkRed 'Could not get installer version information, cannot continue.'
exit
} else {
Write-Host -ForegroundColor Gray "Got installer version $installerversion"
}
# Check if this has already been installed
Write-Host -ForegroundColor Gray 'Checking if already installed...'
try {
$version = (Get-WMIObject -Query "SELECT * FROM Win32_Product Where Name = 'Dell Command | Update'").Version
}
catch {
$message = $_.Exception.message
Write-Error 'WMI query for Dell Command raised exception:'
throw $message
}
if ( $version.Length -gt 0 ) {
Write-Host -ForegroundColor Gray "Already installed, version: $version"
Write-Host -ForegroundColor Gray 'Comparing installed version with available installer...'
if ( $installerversion -gt [Version]$version ) {
Write-Host -ForegroundColor DarkYellow 'Installed version is lower than the available version. The installation will be upgraded.'
} else {
Write-Host -ForegroundColor Green 'Installed version is current or higher than the available version. Nothing else to do now.'
exit
}
} else {
Write-Host -ForegroundColor Gray "Not currently installed"
}
Write-Host -ForegroundColor Yellow 'Running installer...'
# Run the installer
try {
#Start-Process -FilePath $installer -ArgumentList '/s' -Wait -ErrorAction Stop
& $installer /s | Out-Null
Write-Host -ForegroundColor Green 'Installation complete.'
}
catch {
$message = $_.Exception.message
Write-Error 'Installation raised exception:'
throw $message
}
The $installer variable must be set to a file share path that has the installer available.