From 5a2bbaba71e74481e7514df6b35df8f7ba7b04f1 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Mon, 6 Jan 2025 11:23:55 -0500 Subject: [PATCH] Update TGBeta.ps1 --- TGBeta.ps1 | 111 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/TGBeta.ps1 b/TGBeta.ps1 index 14da762..ae71e18 100644 --- a/TGBeta.ps1 +++ b/TGBeta.ps1 @@ -6,15 +6,10 @@ ### Install-SVSHelpDesk ### Install SVSWatchtower - +### Missing the /installSVSMSPModule in the powershell section ### add tweak to set default provider, add to toolkit? -###### Work in progress -### Missing the /installSVSMSPModule in the powershell section -### fixing all the /install... - - # --------------------------------------------------------------------------- # 1) CREATE A GLOBAL LOG CACHE (NEW) # --------------------------------------------------------------------------- @@ -184,17 +179,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 { @@ -962,18 +957,7 @@ try { } } - "/installSVSMSPModule" { - if ($request.HttpMethod -eq "GET") { - Install-SVSMSP -InstallToolkit - - } - $responseString = "Install SVSMSP Module triggered." - $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") { @@ -1054,15 +1038,18 @@ try { "/setSVSPowerplan" { if ($request.HttpMethod -eq "GET") { - try { + + try { Set-SVSPowerPlan - $responseString = "Setting SVSPowerPlan triggered successfully." + $responseString = "Setting SVS PowerPlan triggered successfully." $response.StatusCode = 200 } catch { - $responseString = "Error triggering Setting PowerPlan: $_" + $responseString = "Error triggering Setting SVS PowerPlan: $_" $response.StatusCode = 500 } - + } else { + $responseString = "Method not allowed. Use GET." + $response.StatusCode = 405 } $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $response.ContentType = "text/plain" @@ -1096,9 +1083,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 @@ -1108,9 +1104,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 @@ -1120,9 +1125,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 @@ -1132,9 +1146,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 @@ -1145,8 +1168,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