Create a Custom Detection Script for Dell Command Update (PowerShell)


Microsoft Endpoint Manager Configuration Manager (MEMCM / SCCM) and Microsoft Intune use Detection Rules to determine the presence of Applications & Win32 Apps. The detection rules ensure that application installations only begin to run if the application is not already installed on the device. This article will serve as an informative guide and give you a clear understanding of how to create an updated custom detection script for each new version of Dell Command Update using PowerShell.

How to Create a Custom Detection Script for Dell Command Update

Dell Command Update (File Detection Method)

## Check for Dell Command Update (File Detection Method)
$DCUExe = (Get-ChildItem -Path "C:\Program Files\Dell\CommandUpdate\dcu-cli.exe","C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe" -ErrorAction SilentlyContinue)
$DCUExe.FullName
$DCUPath = $($DCUExe.FullName).Replace("C:\Program Files\","").Replace("C:\Program Files (x86)\","")
$FileVersion = (Get-Item -Path "$($DCUExe.FullName)" -ErrorAction SilentlyContinue).VersionInfo.FileVersion

## Create Text File with Dell Command Update File Detection Method
$FilePath = "C:\Windows\Temp\Dell_Command_Update_Detection_Method.txt"
New-Item -Path "$FilePath" -Force
Set-Content -Path "$FilePath" -Value "If([String](Get-Item -Path `"`$Env:ProgramFiles\$DCUPath`",`"`${Env:ProgramFiles(x86)}\$DCUPath`" -ErrorAction SilentlyContinue).VersionInfo.FileVersion -ge `"$FileVersion`"){"
Add-Content -Path "$FilePath" -Value "Write-Host `"Installed`""
Add-Content -Path "$FilePath" -Value "Exit 0"
Add-Content -Path "$FilePath" -Value "}"
Add-Content -Path "$FilePath" -Value "else {"
Add-Content -Path "$FilePath" -Value "Exit 1"
Add-Content -Path "$FilePath" -Value "}"
Invoke-Item $FilePath

Example:

If([String](Get-Item -Path "$Env:ProgramFiles\Dell\CommandUpdate\dcu-cli.exe","${Env:ProgramFiles(x86)}\Dell\CommandUpdate\dcu-cli.exe" -ErrorAction SilentlyContinue).VersionInfo.FileVersion -ge "4.5.0.61"){
Write-Host "Installed"
Exit 0
}
else {
Exit 1
}

Dell Command Update (Registry Detection Method)

## Check for Dell Command Update (Registry Detection Method)
$DCU = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object {$_.DisplayName -like 'Dell Command | Update*' } | Select-Object -Property DisplayName, DisplayVersion, PSChildName
$DCU.DisplayVersion
$DCU.PSChildName

## Create Text File with Dell Command Update Registry Detection Method
$FilePath = "C:\Windows\Temp\Dell_Command_Update_Detection_Method.txt"
New-Item -Path "$FilePath" -Force
Set-Content -Path "$FilePath" -Value "If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$($DCU.PSChildName)','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$($DCU.PSChildName)' -Name DisplayVersion -ea SilentlyContinue) -ge '$($DCU.DisplayVersion)') {"
Add-Content -Path "$FilePath" -Value "Write-Host `"Installed`""
Add-Content -Path "$FilePath" -Value "Exit 0"
Add-Content -Path "$FilePath" -Value "}"
Add-Content -Path "$FilePath" -Value "else {"
Add-Content -Path "$FilePath" -Value "Exit 1"
Add-Content -Path "$FilePath" -Value "}"
Invoke-Item $FilePath
  • Click Run Script (F5)
  • A text file will open with the Dell Command Update Detection Method script required to detect the current version of Dell Command Update that is installed on the device you are running the script from.

Example:

If([Version](Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FFD8CF3D-3063-4D97-B007-26258E71D02F}','HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{FFD8CF3D-3063-4D97-B007-26258E71D02F}' -Name DisplayVersion -ea SilentlyContinue) -ge '4.5.0') {
Write-Host "Installed"
Exit 0
}
else {
Exit 1
}

Always make sure to test everything in a development environment prior to implementing anything into production. The information in this article is provided “As Is” without warranty of any kind.

Recent Posts