From 4c9518a430e221ebeb84798da3c6e5ae69c6f2f2 Mon Sep 17 00:00:00 2001 From: dyoder Date: Fri, 9 Jul 2021 21:11:54 -0400 Subject: [PATCH] use try/catch blocks, remove remaining files/directories --- Uninstall-NCentralComponents.ps1 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Uninstall-NCentralComponents.ps1 b/Uninstall-NCentralComponents.ps1 index 7cbd236..93fe941 100644 --- a/Uninstall-NCentralComponents.ps1 +++ b/Uninstall-NCentralComponents.ps1 @@ -1,14 +1,23 @@ If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\PME\unins000.exe" ) { LogMsg "Uninstalling N-Central Patch Management Service Controller" - Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\PME\unins000.exe" -ArgumentList "/SILENT" -Wait + Try { Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\PME\unins000.exe" -ArgumentList "/SILENT" -Wait } + Catch { LogErr $_.Exception.Message } } If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\FileCacheServiceAgent\unins000.exe" ) { LogMsg "Uninstalling N-Central File Cache Service Agent" - Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\FileCacheServiceAgent\unins000.exe" -ArgumentList "/SILENT" -Wait + Try { Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\FileCacheServiceAgent\unins000.exe" -ArgumentList "/SILENT" -Wait } + Catch { LogErr $_.Exception.Message } } If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\RequestHandlerAgent\unins000.exe" ) { LogMsg "Uninstalling N-Central Request Handler Agent" - Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\RequestHandlerAgent\unins000.exe" -ArgumentList "/SILENT" -Wait + Try { Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\RequestHandlerAgent\unins000.exe" -ArgumentList "/SILENT" -Wait } + Catch { LogErr $_.Exception.Message } +} + +If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform" ) { + LogMsg "Forcefully removing ""${Env:ProgramFiles(x86)}\MspPlatform""" + Try { Remove-Item "${Env:ProgramFiles(x86)}\MspPlatform" -Recurse -Force } + Catch { LogErr $_.Exception.Message } } \ No newline at end of file