Files
Powershell-Scripts/App Uninstall Scripts/App - Arcserve UDP Agent - Uninstall.ps1
T

84 lines
3.0 KiB
PowerShell

<#
Author: Craig Krautkramer
Date: 07/10/22
.Synopsis
Script uninstalls the Arcserve UDP Agent software. If the backup server software (Console or
Recovery Point Server) is detected, the script will exit.
#>
$App_Name = 'Arcserve UDP Agent'
######################
### Functions ###
######################
Function Get-Software ($CPU = $ENV:PROCESSOR_ARCHITECTURE) {
if ($CPU -eq 'AMD64') {
$32bit = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
$64bit = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
$32bit + $64bit
}
else {
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
}
}
Function Check-ExitCode {
If ($ExitCode -eq 0) {
Write-Host `n
$a = Get-Software | Where-Object { $_.DisplayName -eq $App_Name } | Select DisplayName, DisplayVersion | FL
If ($a -ne $null) {
Write-Host "ERROR: Script reports successful uninstall, but $App_Name still shows in Programs and Features"
$a
}
Else {
Write-Host "$App_Name Successfully Uninstalled."
}
}
ElseIf ($ExitCode -eq 3010) {
Write-Host `n
$a = Get-Software | Where-Object { $_.DisplayName -eq $App_Name } | Select DisplayName, DisplayVersion | FL
If ($a -ne $null) {
Write-Host "ERROR: Script reports successful uninstall, but $App_Name still shows in Programs and Features"
$a
}
Else {
Write-Host "$App_Name Successfully Uninstalled, but requires a reboot to complete."
}
}
Else {
Write-Host `n
Write-Host "ERROR: $App_Name failed to uninstall. Exit Code:" + $ExitCode
}
}
######################
### Script start ###
######################
$Applist = Get-Software | Where-Object { $_.DisplayName -eq $App_Name } | select Displayname, Uninstallstring
$Console = Get-Software | Where-Object { $_.DisplayName -eq 'Arcserve UDP Console' }
$RecoveryPointServer = Get-Software | Where-Object { $_.DisplayName -eq 'Arcserve UDP Recovery Point Server' }
If ($Applist -ne $null) {
If ($Console -ne $null -or $RecoveryPointServer -ne $null) {
Write-Host "This server is the Arcseve UDP Console or RecoveryPoint server. Exiting..."
}
ElseIf ($ENV:PROCESSOR_ARCHITECTURE -eq 'AMD64') {
$UninstallerPath = 'C:\Program Files (x86)\Arcserve\SharedComponents\Arcserve Unified Data Protection\Setup\uninstall.exe'
$ArgumentList = '/q /ALL'
$Uninstall = Start-Process $UninstallerPath -ArgumentList $ArgumentList -wait -PassThru -NoNewWindow
$ExitCode = ($Uninstall).ExitCode
Check-ExitCode
}
Else {
$UninstallerPath = 'C:\Program Files\Arcserve\SharedComponents\Arcserve Unified Data Protection\Setup\uninstall.exe'
$ArgumentList = '/q /ALL'
$Uninstall = Start-Process $UninstallerPath -ArgumentList $ArgumentList -wait -PassThru -NoNewWindow
$ExitCode = ($Uninstall).ExitCode
Check-ExitCode
}
}
Else {
Write-Host "The $App_Name software does not exist on this machine. Exiting..."
}