Hi, I just tested this in our environment.
for evaluation I just did a simple exit 1 since I manually ran this but i suppose you can get creative and look for the program
Eval:
$program = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq "Dell SupportAssist"}
if($program){
exit 1
}else {
exit 0
}
Remediation:
$program = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq "Dell SupportAssist"}
try {
if ($program) {
$ID = $program.IdentifyingNumber
$Name = $program.Name
Write-Host "Uninstalling $Name ..."
$uninstallResult = (Start-Process "C:\WINDOWS\system32\msiexec.exe" -ArgumentList "/x $ID /quiet /norestart" -PassThru -Wait).ExitCode
if ($uninstallResult -eq 0) {
Write-Host "$Name has been uninstalled."
exit 0
} else {
Write-Host "Failed to uninstall $Name."
exit 1
}
} else {
Write-Host "No programs found to uninstall."
exit 0
}
} catch {
Write-Host "An error occurred: $_"
exit 1
}