56 lines
1.6 KiB
PowerShell
56 lines
1.6 KiB
PowerShell
<#
|
|
Author: Gabe Kerntke
|
|
Date: 05-30-2024
|
|
|
|
.Synopsis
|
|
Script checks to see if Mitel is installed, if installed it will uninstall
|
|
|
|
.Modified
|
|
2024-05-30 (GabeK) - Original script created
|
|
|
|
#>
|
|
|
|
######################
|
|
### Variables ###
|
|
######################
|
|
$Name = "Mitel"
|
|
|
|
######################
|
|
### 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 {
|
|
$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
|
|
}
|
|
Else {
|
|
Write-Host "$Name is not installed, exiting script"
|
|
} |