From 68ed03d32ed9d12379779bc3654b69a389156a6f Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Tue, 27 May 2025 00:37:50 -0400 Subject: [PATCH] fixed the install module --- testTaskGate.ps1 | 58 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/testTaskGate.ps1 b/testTaskGate.ps1 index c3c3378..765ed0f 100644 --- a/testTaskGate.ps1 +++ b/testTaskGate.ps1 @@ -219,8 +219,49 @@ function Install-DattoRMM-Helper { } #endregion -# POST /getpw → read JSON body, call helper, return JSON +#region SVS Module +function Install-SVSMSP { + param ( + [switch] $Cleanup, + [switch] $InstallToolkit, + [Parameter(Mandatory = $false)][array] $AllModules = @(@{ ModuleName = "SVS_Toolkit" }, @{ ModuleName = "SVSMSP" }), + [Parameter(Mandatory = $false)][array] $AllRepositories = @(@{ RepoName = "SVS_Repo" }, @{ RepoName = "SVS_Toolkit" }), + [Parameter(Mandatory = $false)][string] $NewModuleName = "SVSMSP", + [Parameter(Mandatory = $false)][string] $NewRepositoryName = "SVS_Repo", + [Parameter(Mandatory = $false)][string] $NewRepositoryURL = "http://proget.svstools.ca:8083/nuget/SVS_Repo/" + ) + + function Perform-Cleanup { + Write-LogHybrid "Cleanup mode enabled. Starting cleanup..." "Info" "SVSModule" + # …your old cleanup logic here… + } + + function Perform-ToolkitInstallation { + Perform-Cleanup + Write-LogHybrid "Registering repo $NewRepositoryName…" "Info" "SVSModule" + if (-not (Get-PSRepository -Name $NewRepositoryName -ErrorAction SilentlyContinue)) { + Register-PSRepository -Name $NewRepositoryName -SourceLocation $NewRepositoryURL -InstallationPolicy Trusted + } + Write-LogHybrid "Installing module $NewModuleName…" "Info" "SVSModule" + Install-Module -Name $NewModuleName -Repository $NewRepositoryName -Scope AllUsers -Force + Write-LogHybrid "Toolkit installation complete." "Success" "SVSModule" + } + + Write-LogHybrid "Install-SVSMSP called" "Info" "SVSModule" + if ($Cleanup) { + Perform-Cleanup; return + } + if ($InstallToolkit) { + Perform-ToolkitInstallation; return + } + # default if no switch passed: + Perform-ToolkitInstallation +} + +#endregion + +# POST /getpw → read JSON body, call helper, return JSON function Handle-FetchSites { param($Context) @@ -302,10 +343,6 @@ function returnRespondEmpty { } - - - - # On-boarding handlers function Set-SVSPowerPlan { param($Context) @@ -314,9 +351,16 @@ function Set-SVSPowerPlan { } function Install-SVSMSPModule { param($Context) - Write-LogHybrid "SVSMSP Module installed" "Success" "OnBoard" - Respond-Text $Context "SVSMSP Module installed" + Write-LogHybrid "HTTP trigger: Install-SVSMSPModule" "Info" "OnBoard" + try { + Install-SVSMSP -InstallToolkit + Respond-Text $Context "SVSMSP Module installed/updated." + } catch { + Write-LogHybrid "Error in Install-SVSMSP: $_" "Error" "OnBoard" + Respond-Text $Context "ERROR: $_" + } } + function Install-CyberQP { param($Context) Write-LogHybrid "CyberQP installed" "Success" "OnBoard"