Update SVSTaskGate.ps1
This commit is contained in:
@@ -863,6 +863,12 @@ try {
|
|||||||
$bodyStream = New-Object IO.StreamReader $request.InputStream
|
$bodyStream = New-Object IO.StreamReader $request.InputStream
|
||||||
$body = $bodyStream.ReadToEnd()
|
$body = $bodyStream.ReadToEnd()
|
||||||
|
|
||||||
|
# Ensure the request body is not empty
|
||||||
|
if (-not $body) {
|
||||||
|
Write-LogHybrid -Message "Request body is empty. Aborting..." -Level "Error"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
# Log raw request body
|
# Log raw request body
|
||||||
Write-LogHybrid -Message "Raw request body: $body" -Level "Info"
|
Write-LogHybrid -Message "Raw request body: $body" -Level "Info"
|
||||||
|
|
||||||
@@ -875,19 +881,26 @@ try {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# Log the received request for debugging
|
# Validate required fields
|
||||||
Write-LogHybrid -Message "Received RMM installation request: $($selectedSite | ConvertTo-Json -Depth 10)" -Level "Info"
|
if (-not $selectedSite.installRMMCommand -or -not $selectedSite.UID -or -not $selectedSite.Name) {
|
||||||
Write-LogHybrid -Message "Starting installation for site $($selectedSite.Name) ($($selectedSite.UID))..." -Level "Info"
|
Write-LogHybrid -Message "Missing required fields in JSON payload. Aborting..." -Level "Error"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# Log the received request
|
||||||
|
Write-LogHybrid -Message "Received RMM installation request for site $($selectedSite.Name) ($($selectedSite.UID))." -Level "Info"
|
||||||
|
|
||||||
# Execute the installation command
|
# Execute the installation command
|
||||||
try {
|
try {
|
||||||
Invoke-Expression $selectedSite.installRMMCommand
|
$output = Invoke-Expression $selectedSite.installRMMCommand
|
||||||
|
Write-LogHybrid -Message "Command output: $output" -Level "Info"
|
||||||
Write-LogHybrid -Message "Installation for site $($selectedSite.Name) ($($selectedSite.UID)) completed successfully." -Level "Success"
|
Write-LogHybrid -Message "Installation for site $($selectedSite.Name) ($($selectedSite.UID)) completed successfully." -Level "Success"
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-LogHybrid -Message "Error during installation for site $($selectedSite.Name): $($_.Exception.Message)" -Level "Error"
|
Write-LogHybrid -Message "Error during installation for site $($selectedSite.Name): $($_.Exception.Message)" -Level "Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Send response
|
||||||
$responseString = "RMM installation triggered for site $($selectedSite.Name)."
|
$responseString = "RMM installation triggered for site $($selectedSite.Name)."
|
||||||
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
||||||
$response.ContentType = "text/plain"
|
$response.ContentType = "text/plain"
|
||||||
@@ -898,6 +911,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