Update SVSTaskGate.ps1

This commit is contained in:
2025-01-05 01:09:15 -05:00
parent f962fecf0d
commit 460d4e8234

View File

@@ -856,37 +856,22 @@ try {
} }
} }
"/installrmm" { "/installrmm" {
if ($request.HttpMethod -eq "POST") { if ($request.HttpMethod -eq "POST") {
$bodyStream = New-Object IO.StreamReader $request.InputStream $bodyStream = New-Object IO.StreamReader $request.InputStream
$body = $bodyStream.ReadToEnd() $body = $bodyStream.ReadToEnd()
$selectedSite = ConvertFrom-Json $body $requestData = ConvertFrom-Json $body
# Extract parameters $installRMMCommand = $requestData.installRMMCommand
#$ApiUrl = $selectedSite.ApiUrl $UID = $requestData.UID
#$ApiKey = $selectedSite.ApiKey $Name = $requestData.Name
#$ApiSecretKey = $selectedSite.ApiSecretKey
# Verify required parameters # Log the received command
if (-not $ApiUrl -or -not $ApiKey -or -not $ApiSecretKey) { Write-LogHybrid -Message "Received command: $installRMMCommand for UID: $UID, Name: $Name" -Level "Info"
$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 { try {
Invoke-Expression $installCommand Invoke-Expression $installRMMCommand
$responseString = "RMM install triggered successfully." $responseString = "RMM install triggered successfully for UID: $UID, Name: $Name."
} }
catch { catch {
$responseString = "Error triggering RMM install: $($_.Exception.Message)" $responseString = "Error triggering RMM install: $($_.Exception.Message)"
@@ -902,6 +887,9 @@ try {
"/setSVSPowerplan" { "/setSVSPowerplan" {
if ($request.HttpMethod -eq "GET") { if ($request.HttpMethod -eq "GET") {
Set-SVSPowerPlan Set-SVSPowerPlan