From 6878c2b0d526c458e69b7c370709dd621a2866e5 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Mon, 6 Jan 2025 14:52:53 -0500 Subject: [PATCH] Update SVSTaskGate.ps1 --- SVSTaskGate.ps1 | 128 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 98 insertions(+), 30 deletions(-) diff --git a/SVSTaskGate.ps1 b/SVSTaskGate.ps1 index 11bda61..5d66404 100644 --- a/SVSTaskGate.ps1 +++ b/SVSTaskGate.ps1 @@ -1,12 +1,5 @@ ### Known issues as of January 5 2025 -### Install-DattoRMM version 25.1.4 is missing functions you'll need version 25.1.5 - -### Missing Function in module, are added in 25.1.5 -### Install-SVSHelpDesk -### Install SVSWatchtower - -### Missing the /installSVSMSPModule in the powershell section ### add tweak to set default provider, add to toolkit? @@ -132,9 +125,7 @@ else { } # Example usage of Write-LogHybrid -Write-LogHybrid -Message "This is a test log message. Write-logHybrid" -Level "Info" -TaskCategory "TestCategory" -LogToEvent:$true -Write-Log -Message "This is a test log message. Write-log" -Level "Info" -TaskCategory "TestCategory" -LogToEvent:$true - +Write-LogHybrid -Message "Starting SVS TaskGate" -Level "Info" -TaskCategory "SVSTaskGate" -LogToEvent:$true function Install-SVSMSP { param ( @@ -179,17 +170,17 @@ function Install-SVSMSP { # Log file path [Parameter(Mandatory = $false)] - [string]$LogFilePath = "$env:temp\svstoolkit.log", + [string]$LogFilePath = "$env:SVSMSP\svstoolkit.log", # DRMM API Settings [Parameter(Mandatory = $false)] - [string]$ApiUrl = "https://example-api-url.com", + [string]$ApiUrl, [Parameter(Mandatory = $false)] - [string]$ApiKey = "YOUR_API_KEY_HERE", + [string]$ApiKey, [Parameter(Mandatory = $false)] - [string]$ApiSecretKey = "YOUR_API_SECRET_HERE" + [string]$ApiSecretKey ) function Perform-Cleanup { @@ -957,6 +948,28 @@ try { } } + "/installSVSMSPModule" { + if ($request.HttpMethod -eq "GET") { + try { + Install-SVSMSP -InstallToolkit + $responseString = "Install SVSMSP Module triggered successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error triggering Install SVSMSP Module: $_" + $response.StatusCode = 500 + } + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 + } + $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() + + } + "/installrmm" { if ($request.HttpMethod -eq "POST") { try { @@ -1036,9 +1049,19 @@ try { "/setSVSPowerplan" { if ($request.HttpMethod -eq "GET") { - Set-SVSPowerPlan + + try { + Set-SVSPowerPlan + $responseString = "Setting SVS PowerPlan triggered successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error triggering Setting SVS PowerPlan: $_" + $response.StatusCode = 500 + } + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 } - $responseString = "Install SVS Powerplan triggered." $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length @@ -1061,7 +1084,6 @@ try { $responseString = "Method not allowed. Use GET." $response.StatusCode = 405 } - $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length @@ -1072,9 +1094,18 @@ try { "/installSplashtop" { if ($request.HttpMethod -eq "GET") { - Install-Splashtop + try { + Install-Splashtop + $responseString = "Install Splashtop triggered successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error triggering Install Splashtop: $_" + $response.StatusCode = 500 + } + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 } - $responseString = "Install Splashtop triggered." $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length @@ -1084,9 +1115,18 @@ try { "/installRocketCyber" { if ($request.HttpMethod -eq "GET") { - Install-RocketCyber - } - $responseString = "Install RocketCyber triggered." + try { + Install-RocketCyber + $responseString = "Install RocketCyber triggered successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error triggering Install RocketCyber: $_" + $response.StatusCode = 500 + } + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 + } $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length @@ -1096,9 +1136,18 @@ try { "/installThreatLocker" { if ($request.HttpMethod -eq "GET") { - Install-ThreatLocker - } - $responseString = "Install ThreatLocker triggered." + try { + Install-ThreatLocker + $responseString = "Install ThreatLocker triggered successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error triggering Install ThreatLocker: $_" + $response.StatusCode = 500 + } + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 + } $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length @@ -1108,9 +1157,18 @@ try { "/installSVSHelpDesk" { if ($request.HttpMethod -eq "GET") { - Install-SVSHelpDesk - } - $responseString = "Install SVSHelpDesk triggered." + try { + Install-SVSHelpDesk + $responseString = "Install SVSHelpDesk triggered successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error triggering Install SVSHelpDesk: $_" + $response.StatusCode = 500 + } + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 + } $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length @@ -1121,8 +1179,18 @@ try { "/installSVSWatchtower" { if ($request.HttpMethod -eq "GET") { Install-SVSWatchtower - } - $responseString = "Install SVSWatchtower triggered." + try { + Install-SVSWatchtower + $responseString = "Install SVSWatchtower triggered successfully." + $response.StatusCode = 200 + } catch { + $responseString = "Error triggering Install SVSWatchtower: $_" + $response.StatusCode = 500 + } + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 + } $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" $response.ContentLength64 = $buffer.Length