Uninstalling Dell Applications

 avatar
unknown
powershell
2 years ago
1.3 kB
12
Indexable
<#
.SYNOPSIS
    This script uninstalls any applications with "Dell" in the name using msiexec.
    
.DESCRIPTION
    This script searches for applications that have "Dell" in their name, retrieves the MSI code for each, 
    and then executes an msiexec /x command to uninstall them.

.AUTHOR
    Jack Harvard, ComputerWorld
#>

# Ensure the script is run with admin privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
    Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File $($MyInvocation.MyCommand)" -Verb RunAs
    exit
}

# Search for all applications with "Dell" in the name and get their MSI code
$apps = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*Dell*" } | Select-Object -ExpandProperty IdentifyingNumber

# Uninstall each of these applications using msiexec /x
foreach ($app in $apps) {
    Write-Host "Uninstalling application with MSI code: $app"
    Start-Process -Wait "msiexec" -ArgumentList "/x $app /qn /norestart"
    Write-Host "Uninstalled application with MSI code: $app"
}

Write-Host "All Dell applications have been uninstalled."
Editor is loading...