From dd57dbefc6f22dfa9ffdb3133a2772649abf5506 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sat, 4 Jan 2025 03:03:45 -0500 Subject: [PATCH] Update SVSTaskGate.ps1 --- SVSTaskGate.ps1 | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/SVSTaskGate.ps1 b/SVSTaskGate.ps1 index af085f7..0ae19d6 100644 --- a/SVSTaskGate.ps1 +++ b/SVSTaskGate.ps1 @@ -855,20 +855,35 @@ try { } } + + "/installrmm" { if ($request.HttpMethod -eq "POST") { $bodyStream = New-Object IO.StreamReader $request.InputStream $body = $bodyStream.ReadToEnd() $selectedSite = ConvertFrom-Json $body - - $installCommand = $selectedSite.installRMMCommand - # Ensure API parameters are included - $installCommand += " -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$ApiSecretKey'" - + # Extract parameters + $ApiUrl = $selectedSite.ApiUrl + $ApiKey = $selectedSite.ApiKey + $ApiSecretKey = $selectedSite.ApiSecretKey + + # Verify required parameters + if (-not $ApiUrl -or -not $ApiKey -or -not $ApiSecretKey) { + $responseString = "Error: Missing required parameters. ApiUrl='$ApiUrl', ApiKey='$ApiKey', ApiSecretKey='$ApiSecretKey'" + $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) + $response.ContentType = "text/plain" + $response.ContentLength64 = $buffer.Length + $response.OutputStream.Write($buffer, 0, $buffer.Length) + $response.OutputStream.Close() + return + } + + # Construct the command + $installCommand = "Install-DattoRMM -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$ApiSecretKey'" + Write-LogHybrid -Message "Executing command: $installCommand" -Level "Info" + try { - Write-LogHybrid -Message "Executing command: $installCommand" -Level "Info" - Invoke-Expression $installCommand $responseString = "RMM install triggered successfully." } @@ -885,6 +900,7 @@ try { } + "/setSVSPowerplan" { if ($request.HttpMethod -eq "GET") { Set-SVSPowerPlan