Files

58 lines
1.7 KiB
PowerShell
Raw Permalink Normal View History

2025-08-06 23:40:24 +00:00
<#
Author: Gabe Kerntke
Company: UFS LLC
Date: 02-15-2024
.Synopsis
Script checks to see if Citrix Workspace is installed, if it is then it will find the uninstall string from registry and uninstall it via that method
.Modified
2024-02-15 (GabeK) - Original script created
#>
######################
### Variables ###
######################
$Name = "Citrix Workspace"
######################
### 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 program via Registry UninstallString
Function Uninstall {
$Registry = $Applist | Select-Object -ExpandProperty UninstallString
$Command = $Registry += " -silent"
cmd /c $Command
If ($Applist.DisplayName -like "*$Name*") {
Write-Host "Failed to uninstall $Name"
}
Else {
Write-Host "$Name uninstalled successfully"
}
}
######################
### 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"
}