Files

92 lines
6.3 KiB
PowerShell
Raw Permalink Normal View History

2025-08-06 23:43:11 +00:00
<#
Author: Gabe Kerntke
Date: 05-28-2024
.Synopsis
Script checks to see if Dell SupportAssist is installed, if installed it will uninstall
.Modified
2024-05-28 (GabeK) - Original script created
2025-04-09 (GabeK) - Rewrote script since it was bluescreening systems
#>
# Variables #
$Name = "Dell SupportAssist"
$StoreVersion = "Get-AppxPackage | Select-Object Name, PackageFullName | Format-List"
# Functions #
#Function checks for 32 or 64 bit processor and then pulls list of applications accordingly
Function Get-Software ($CPU = $ENV:PROCESSOR_ARCHITECTURE) {
If ($CPU -eq 'AMD64') {
$64bit = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
$32bit = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
$32bit + $64bit
}
Else { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* }
}
Function Uninstall-App {
If ($StoreVersion -contains "*DellSupport*") {
Get-AppxPackage -Name "*DellSupport*" | Select-Object -ExpandProperty PackageFullName | Remove-AppPackage
Start-Sleep 10
Uninstall-App2
}
Else { Uninstall-App2 }
}
Function Uninstall-App2 {
$UninstallString = $Applist | Select-Object -ExpandProperty QuietUninstallString -ErrorAction SilentlyContinue
If ($null -eq $UninstallString) {
$UninstallString = $Applist | Select-Object -ExpandProperty UninstallString
$UninstallString + " /qn /quiet /norestart" | cmd
Start-Sleep 10
}
Else {
$UninstallString | cmd
Start-Sleep 10
}
If (Get-Software | Where-Object { $_.DisplayName -eq "$Name" -or $_.DisplayName -eq "$Name Remediation" }) {
Uninstall-App3
}
Else {
Write-Host "$Name uninstalled successfully"
Remove-Folder
}
}
Function Uninstall-App3 {
$UninstallString2 = $Applist | Select-Object -ExpandProperty PSPath
$B = $UninstallString2 -replace "Microsoft.PowerShell.Core", ""
$C = $B.Substring(1)
Remove-Item -ErrorAction SilentlyContinue -Path $C -Force -Verbose
Start-Sleep 10
If (Get-Software | Where-Object { $_.DisplayName -eq "$Name" }) {
Write-Host "$Name uninstall failed, exting script"
}
Else {
Write-Host "$Name uninstalled successfully"
Remove-Folder
}
}
Function Remove-Folder {
If (Test-Path "C:\Program Files\Dell\SupportAssistAgent") {
Remove-Item -ErrorAction SilentlyContinue -Path "C:\Program Files\Dell\SupportAssistAgent" -Recurse -Force
}
If (Test-Path "C:\Program Files\Dell\SARemediation") {
Remove-Item -ErrorAction SilentlyContinue -Path "C:\Program Files\Dell\SARemediation" -Recurse -Force
}
}
# Script start #
#Check to see if program is installed
$Applist = Get-Software | Where-Object { $_.DisplayName -eq "$Name" -or $_.DisplayName -eq "$Name Remediation" }
If ($Applist | Where-Object { $_.DisplayName -eq "$Name" -or $_.DisplayName -eq "$Name Remediation" }) {
Uninstall-App
}
Else {
Write-Host "$Name is not installed, exiting script"
}
# Script End #