Update SVSTaskGate.ps1
This commit is contained in:
@@ -855,20 +855,35 @@ 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
|
$selectedSite = ConvertFrom-Json $body
|
||||||
|
|
||||||
$installCommand = $selectedSite.installRMMCommand
|
# Extract parameters
|
||||||
|
$ApiUrl = $selectedSite.ApiUrl
|
||||||
|
$ApiKey = $selectedSite.ApiKey
|
||||||
|
$ApiSecretKey = $selectedSite.ApiSecretKey
|
||||||
|
|
||||||
# Ensure API parameters are included
|
# Verify required parameters
|
||||||
$installCommand += " -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$ApiSecretKey'"
|
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
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
# Construct the command
|
||||||
|
$installCommand = "Install-DattoRMM -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$ApiSecretKey'"
|
||||||
Write-LogHybrid -Message "Executing command: $installCommand" -Level "Info"
|
Write-LogHybrid -Message "Executing command: $installCommand" -Level "Info"
|
||||||
|
|
||||||
|
try {
|
||||||
Invoke-Expression $installCommand
|
Invoke-Expression $installCommand
|
||||||
$responseString = "RMM install triggered successfully."
|
$responseString = "RMM install triggered successfully."
|
||||||
}
|
}
|
||||||
@@ -885,6 +900,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"/setSVSPowerplan" {
|
"/setSVSPowerplan" {
|
||||||
if ($request.HttpMethod -eq "GET") {
|
if ($request.HttpMethod -eq "GET") {
|
||||||
Set-SVSPowerPlan
|
Set-SVSPowerPlan
|
||||||
|
|||||||
Reference in New Issue
Block a user