From 9110724d5d4151825b47cb1b26dfda383d33c897 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Fri, 3 Jan 2025 23:47:30 -0500 Subject: [PATCH] Update SVSTaskGate.ps1 --- SVSTaskGate.ps1 | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/SVSTaskGate.ps1 b/SVSTaskGate.ps1 index 10666c6..269de28 100644 --- a/SVSTaskGate.ps1 +++ b/SVSTaskGate.ps1 @@ -708,9 +708,26 @@ function GetHtmlContent { fetch('/installrmm', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ installRMMCommand, UID, Name, ApiUrl, ApiKey, ApiSecretKey }) + body: JSON.stringify({ + installRMMCommand, + UID, + Name, + ApiUrl, + ApiKey, + ApiSecretKey + }) + }) + .then(response => response.text()) + .then(data => { + console.log('RMM Installation Request Sent:', data); // Log confirmation in browser console + appendLog("Installation request sent to backend.", "green"); + }) + .catch(error => { + console.error('Error:', error); + appendLog("Error sending installation request to backend: " + error.message, "red"); }); - } + + } if (document.querySelector('input[name="setSVSPowerplan"]').checked) { fetch('/installSVSPowerplan', { method: 'GET' }); @@ -848,9 +865,21 @@ try { $bodyStream = New-Object IO.StreamReader $request.InputStream $body = $bodyStream.ReadToEnd() $selectedSite = ConvertFrom-Json $body - Invoke-Expression $selectedSite.installRMMCommand + + # Log the received request for debugging + Write-LogHybrid -Message "Received RMM installation request: $($selectedSite | ConvertTo-Json)" -Level "Info" + Write-LogHybrid -Message "Starting installation for site $($selectedSite.Name) ($($selectedSite.UID))..." -Level "Info" - $responseString = "RMM install triggered." + # Execute the installation command + try { + Invoke-Expression $selectedSite.installRMMCommand + Write-LogHybrid -Message "Installation for site $($selectedSite.Name) ($($selectedSite.UID)) completed successfully." -Level "Success" + } + catch { + Write-LogHybrid -Message "Error during installation for site $($selectedSite.Name): $($_.Exception.Message)" -Level "Error" + } + + $responseString = "RMM installation triggered for site $($selectedSite.Name)." $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length