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