From 1afaefe31005f9d6a21c2d776d15abbac4e9e2ae Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Wed, 2 Jul 2025 21:45:14 -0400 Subject: [PATCH] fixed the perform-cleanup function --- StackMonkey.ps1 | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index d96e79b..05be653 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -217,9 +217,33 @@ ) function Perform-Cleanup { - Write-LogHybrid "Cleanup mode enabled. Starting cleanup..." "Info" "SVSModule" - # …your old cleanup logic here… - } + Write-LogHybrid "Cleanup mode enabled. Starting cleanup..." "Info" "SVSModule" + + # Uninstall all versions of the module from all users + try { + Uninstall-Module -Name SVSMSP -AllVersions -Force -Confirm:$false + Write-LogHybrid "SVSMSP module uninstalled from system." "Success" "SVSModule" + } catch { + Write-LogHybrid "Failed to uninstall SVSMSP: $($_.Exception.Message)" "Error" "SVSModule" + } + + # Remove repository if you registered one + if (Get-PSRepository -Name SVS_Repo -ErrorAction SilentlyContinue) { + try { + Unregister-PSRepository -Name SVS_Repo + Write-LogHybrid "SVS_Repo repository unregistered." "Success" "SVSModule" + } catch { + Write-LogHybrid "Failed to unregister SVS_Repo: $($_.Exception.Message)" "Error" "SVSModule" + } + } + + # Finally, remove it from the current session if loaded + if (Get-Module -Name SVSMSP) { + Remove-Module SVSMSP -Force + Write-LogHybrid "SVSMSP module removed from current session." "Success" "SVSModule" + } + } + function Perform-ToolkitInstallation { Perform-Cleanup