Update SVSTaskGate.ps1

This commit is contained in:
2025-01-04 03:03:45 -05:00
parent a23daa53ed
commit dd57dbefc6

View File

@@ -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
# Extract parameters
$ApiUrl = $selectedSite.ApiUrl
$ApiKey = $selectedSite.ApiKey
$ApiSecretKey = $selectedSite.ApiSecretKey
# Ensure API parameters are included
$installCommand += " -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$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