diff --git a/SVSTaskGate.ps1 b/SVSTaskGate.ps1 index 5d55208..621a8b9 100644 --- a/SVSTaskGate.ps1 +++ b/SVSTaskGate.ps1 @@ -860,10 +860,21 @@ try { $bodyStream = New-Object IO.StreamReader $request.InputStream $body = $bodyStream.ReadToEnd() $selectedSite = ConvertFrom-Json $body - Invoke-Expression $selectedSite.installRMMCommand + + $installCommand = $selectedSite.installRMMCommand - $responseString = "RMM install triggered." - $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) + # Ensure API parameters are included + $installCommand += " -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$ApiSecretKey'" + + try { + Invoke-Expression $installCommand + $responseString = "RMM install triggered successfully." + } + catch { + $responseString = "Error triggering RMM install: $($_.Exception.Message)" + } + + $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length $response.OutputStream.Write($buffer, 0, $buffer.Length) @@ -871,6 +882,7 @@ try { } } + "/setSVSPowerplan" { if ($request.HttpMethod -eq "GET") { Set-SVSPowerPlan