Disclaimer - this will apply all Dell driver updates without a reboot. It is up to you to configure this to your environment.
This worklet will Install Dell Command Update. Be sure to include the binaries and update the name to the EXE you use. https://www.dell.com/support/home/en-us/drivers/DriversDetails?driverId=JDXHH
Once installed or if already installed the worklet is setup to install updates then parse through a log to provide some details on what updates, if any were installed.
Activity Log Output
Evaluation Code
$system = Get-WmiObject win32_computersystem
IF($system.Manufacturer -match "Dell"){ Exit 1 }else { Exit 0 }
Remediation Code
# Dell Command | Update executable uploaded to worklet
$exe = 'Dell-Command-Update-Application-for-Windows10_JDXHH_WIN_4.2.0_A00.EXE'
# Dell Command Version
[version]$version = '4.2.0'
# Log location
$log = 'C:\Windows\Temp\DellCommand_Install.txt'
$system = Get-WmiObject win32_computersystem
IF($system.Manufacturer -match "Dell"){
# Find versions of Dell Command installed
$scriptblock = {
Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' | where DisplayName -match 'Dell Command'
}
# Run the scriptblock and store results in the $64bit variable
$software = & "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -NonInteractive -Command $scriptblock
function Install-DellCommand{
[void](Start-Process -FilePath $exe -ArgumentList "/s /l='$log'" -wait -PassThru)
IF($? -eq "True"){
return $true
}else{
return $false
}
Start-Sleep -Seconds 20
# Configure Dell Command Update
Write-Host
$Arguments = 'scheduleAuto',
'lockSettings=enable',
'userConsent=disable',
'scheduleMonthly=28,00:45',
'scheduledReboot=0',
'autoSuspendBitLocker=enable'
foreach ($Arg in $Arguments){
$results = Start-Process -FilePath "C:\Program Files\Dell\CommandUpdate\dcu-cli.exe" -ArgumentList "/configure -$Arg" -Wait | Out-Null
Start-Sleep -Seconds 5
}
}
# IF Dell Command is not installed or older version exists
IF(!$software){
Write-Output "Installing Dell Command. "
IF(Install-DellCommand){Write-Output "Installed Dell Command. "}else{Write-Output "Failed to install Dell Command. "; exit 1}
}else{
# Remove older versions of Dell Command
foreach ($title in $software){
IF([version]$title.DisplayVersion -lt $version){
Write-Output "Uninstall Dell Command $($title.DisplayVersion). "
$UninstallString = $title.UninstallString | Select-String -Pattern '{[-0-9A-F]+?}' -AllMatches | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value
Start-Process MsiExec -ArgumentList "/X $UninstallString /qn" -Wait
Write-Output "Installing Dell Command. "
IF(Install-DellCommand){Write-Output "Installed Dell Command. "}else{Write-Output "Failed to install Dell Command. "; exit 1}
}
}
}
# Apply Updates
Function Start-DellCommandUpdates {
# 2 minute timeout if dcu-cli is already running
$dcu = Get-Process dcu-cli -ErrorAction SilentlyContinue
IF($dcu){
Write-Output "dcu-cli currently running. Wait for process to complete. "
$startDate = Get-Date
do{}while((Get-Process dcu-cli -ea SilentlyContinue) -and $startDate.AddMinutes(2) -gt (Get-Date))
$dcu = Get-Process dcu-cli -ErrorAction SilentlyContinue
IF($dcu){Stop-Process dcu-cli -Force}
}
# Run dcu-cli
Write-Output "Starting Dell Command Update Process. "
Start-Process -FilePath "C:\Program Files\Dell\CommandUpdate\dcu-cli.exe" -ArgumentList "/applyUpdates" -Wait
}
Start-DellCommandUpdates
# Get Activity
Function Get-DellCommandActivity {
# Get Activity Log and parse intalled updates in last 24 hours
[xml]$a = Get-Content "C:\ProgramData\dell\UpdateService\Log\Activity.log"
$range = (Get-Date).AddHours(-24)
# Write output on Checking Updates
$events = $a.LogEntries.LogEntry | Select timestamp,message | where {[datetime]$_.timestamp -gt $range -and ($_.message -match 'found' -or $_.message -match 'Checking for updates' -or $_.message -match 'verified')} | % {
$timestamp = (Get-Date $_.timestamp -Format 'yyyy-MM-dd hh:mm tt')
$message = $_.message.replace(' verified.','')
[pscustomobject] @{
timestamp = $timestamp
message = $message
}
}
foreach ($event in $events)
{
Write-Output "$($event.timestamp) $($event.message). "
}
}
$activity = Get-DellCommandActivity
foreach ($event in $activity){
Write-Output "$event"
}
IF($activity.count -eq 0){
Write-Output "Something went wrong. Trying to run Dell Command Update again. "
Get-Process dcu-cli -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue -Force
Start-DellCommandUpdates
$activity = Get-DellCommandActivity
foreach ($event in $activity){
Write-Output "$event"
}
IF($activity.count -eq 0){
IF(Test-Path 'C:\Program Files\Dell\CommandUpdate\dcu-cli.exe'){
Write-Output "Something isn't working right. Recommend running this locally and analyzing output: 'C:\Program Files\Dell\CommandUpdate\dcu-cli.exe' /applyUpdates "
Write-Output $activity
}else{Write-Output "Dell Command failed to install. "}
}
}
}else{Write-Host "Not recognized as Dell Manufacturer. Not running." }