Uninstall software via Powershell script

I’ve been trying to uninstall a large amount of unwanted software off the network. After a great deal of reading, I have the following as a powershell script. The script is pretty easy to modify/add to if required, you can just put whatever you want at the end of the script, specifying a different variable for each unique piece of software. It isn’t foolproof, as it relies on the software installing with an MSI file so Google Chrome for example, installs to a unique location (C:\Program Files\Google\Chrome\Application\%Version Number%\Installer\Setup.exe) and can’t be uninstalled this way.

The powershell script is called with a computer startup script which has the following in it:


powershell -executionpolicy bypass -file \\Server-Name\Share-Name\Script-Name.ps1


The PS1 script then has the following:


#Run Powershell as Admin

function Set-Elevation
# Create a new process object that starts PowerShell
$newProcess = New-Object System.Diagnostics.ProcessStartInfo “powershell”;
# Indicate that the process should be elevated
$newProcess.Verb = “runas”;
# Start the new process
[System.Diagnostics.Process]::Start($newProcess) | Out-Null

# Uninstall MS Bing Bar
$Bingbar = Get-WmiObject -Class win32_product -Filter “Name = ‘Bing Bar'”
msiexec /x $Bingbar.localPackage /qn /norestart

# Uninstall Google Earth
$GoogleEarth = Get-WmiObject -Class win32_product -Filter “Name = ‘Google Earth'”
msiexec /x $GoogleEarth.localPackage /qn /norestart


When I work out how to uninstall Chrome etc. easily, I’ll post again.