Upload files to "App Uninstall Scripts"

This commit is contained in:
2025-08-06 23:54:35 +00:00
parent 0c5d09a975
commit 705d71ca1c
@@ -0,0 +1,56 @@
<#
Author: Gabe Kerntke
Date: 02-19-2025
.Synopsis
Script checks to see if Chrome is installed, if installed it will uninstall
.Modified
2025-02-19 (GabeK) - Original script created
#>
######################
### Variables ###
######################
$Name = "Zoom Outlook"
######################
### 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 to uninstall via WMIobject (control panel)
Function Uninstall-App {
$Uninstall = Get-WmiObject Win32_Product -filter "name like '$Name%'" | ForEach-Object { $_.Uninstall() }
$Value = $Uninstall | Select-Object -ExpandProperty ReturnValue
If ($Value -eq "0") {
Write-Host "$Name uninstalled successfully"
}
else {
Write-Host "Failed to uninstall $Name, exiting script"
}
}
######################
### Script start ###
######################
#Check to see if program is installed
$Applist = Get-Software | Where-Object { $_.DisplayName -like "*$Name*" }
If ($Applist.DisplayName -like "*$Name*") {
Uninstall-App
}
Else {
Write-Host "$Name is not installed, exiting script"
}