Upload files to "App Uninstall Scripts"
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<#
|
||||
Author: Gabe Kerntke
|
||||
Date: 12-17-2024
|
||||
|
||||
.Synopsis
|
||||
|
||||
.Modified
|
||||
2024-12-17 (GabeK) - Original script created
|
||||
#>
|
||||
|
||||
# Variables #
|
||||
|
||||
# Functions #
|
||||
|
||||
Function Stop-PuTTYProcess {
|
||||
$puttyProcess = Get-Process -Name "putty" -ErrorAction SilentlyContinue
|
||||
if ($puttyProcess) {
|
||||
Write-Output "Stopping PuTTY process..."
|
||||
Stop-Process -Name "putty" -Force
|
||||
}
|
||||
}
|
||||
Function Remove-PuTTY {
|
||||
param (
|
||||
[string]$path
|
||||
)
|
||||
$paths = "$env:ProgramFiles\PuTTY", "$env:ProgramFiles(x86)\PuTTY"
|
||||
foreach ($path in $paths) {
|
||||
if (Test-Path "$path\unins000.exe") {
|
||||
Write-Output "Deleting $path\putty.exe..."
|
||||
Remove-Item -Force "$path\putty.exe"
|
||||
Write-Output "Uninstalling PuTTY EXE Found in $path ..."
|
||||
Start-Process -FilePath "$path\unins000.exe" -ArgumentList "/SILENT" -Wait
|
||||
}
|
||||
elseif (Test-Path "$path\putty.exe") {
|
||||
Write-Output "Deleting $path\putty.exe..."
|
||||
Remove-Item -Force "$path\putty.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
Function Remove-PuttyMSI {
|
||||
$AppName = "PuTTY"
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Output "Checking if there are any msi-based installations for $AppName..."
|
||||
#-------------------------------------------------------------------------------
|
||||
FOREACH ( $Architecture in "SOFTWARE", "SOFTWARE\Wow6432Node" ) {
|
||||
$UninstallKeys = "HKLM:\$Architecture\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||
IF (Test-path $UninstallKeys) {
|
||||
Write-Output "Checking for $AppName installation in $UninstallKeys"
|
||||
$GUID = Get-ItemProperty -Path "$UninstallKeys\*" |
|
||||
Where-Object -FilterScript { $_.DisplayName -like "$AppName*" } |
|
||||
Select-Object PSChildName -ExpandProperty PSChildName
|
||||
IF ( $GUID ) {
|
||||
$GUID | ForEach-Object {
|
||||
Write-Output "Uninstalling: $(( Get-ItemProperty "$UninstallKeys\$_" ).DisplayName) "
|
||||
Start-Process -Wait -FilePath "MsiExec.exe" -ArgumentList "/X$_ /qn /norestart"
|
||||
}
|
||||
}
|
||||
ELSE {
|
||||
Write-Output "$AppName installation not found in $UninstallKeys"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# Start Script #
|
||||
|
||||
# Stop PuTTY process if running
|
||||
Stop-PuTTYProcess
|
||||
# Check and delete PuTTY installations
|
||||
Write-Output "Checking for PuTTY EXE Installations..."
|
||||
Remove-PuTTY
|
||||
Write-Output "Checking for PuTTY MSI Installations..."
|
||||
Remove-PuTTYMSI
|
||||
# End Script #
|
||||
Reference in New Issue
Block a user