Update SVSTaskGate.ps1

This commit is contained in:
2025-01-05 02:50:10 -05:00
parent 620c1640a2
commit 224bdf16db

View File

@@ -687,87 +687,80 @@ function GetHtmlContent {
function triggerInstall() { function triggerInstall() {
const dropdown = document.getElementById('dattoRmmDropdown'); const dropdown = document.getElementById('dattoRmmDropdown');
const UID = dropdown.options[dropdown.selectedIndex].value; const UID = dropdown.options[dropdown.selectedIndex]?.value || "";
const Name = dropdown.options[dropdown.selectedIndex].text; const Name = dropdown.options[dropdown.selectedIndex]?.text || "";
const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]'); const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]').checked;
const installSVSMSPModule = document.querySelector('input[name="installSVSMSPModule"]'); const installCyberQP = document.querySelector('input[name="installCyberQP"]').checked;
const installDattoRMM = document.querySelector('input[name="installDattoRMM"]'); const installSplashtop = document.querySelector('input[name="installSplashtop"]').checked;
const installCyberQP = document.querySelector('input[name="installCyberQP"]'); const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]').checked;
const installSplashtop = document.querySelector('input[name="installSplashtop"]'); const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]').checked;
const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]'); const installThreatLocker = document.querySelector('input[name="installThreatLocker"]').checked;
const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]'); const installRocketCyber = document.querySelector('input[name="installRocketCyber"]').checked;
const installThreatLocker = document.querySelector('input[name="installThreatlocker"]'); const installDattoRMM = document.querySelector('input[name="installDattoRMM"]').checked;
const installRocketCyber = document.querySelector('input[name="installRocketCyber"]');
if (installDattoRMM.checked) { if (installDattoRMM) {
const DattoRMMCheckbox = document.querySelectorAll('input[name="dattoRMMOption"]:checked'); const dattoRMMOptions = Array.from(
appendLog("Installing selected site RMM...", "cyan"); document.querySelectorAll('input[name="dattoRMMOption"]:checked')
).map(option => option.value);
const checkedValues = Array.from(DattoRMMCheckbox).map(c => c.value); const payload = {
UID,
// Predefined PowerShell global variables passed into JavaScript Name,
const ApiUrl = "$global:ApiUrl"; dattoRMMOptions
const ApiKey = "$global:ApiKey"; };
const ApiSecretKey = "$global:ApiSecretKey";
let installRMMCommand = `Install-DattoRMM -ApiUrl '${ApiUrl}' -ApiKey '${ApiKey}' -ApiSecretKey '${ApiSecretKey}'`;
if (checkedValues.includes('inputVar')) {
installRMMCommand += ' -PushSiteVars';
}
if (checkedValues.includes('rmm')) {
installRMMCommand += ' -InstallRMM';
}
if (checkedValues.includes('exe')) {
installRMMCommand += ' -SaveCopy';
}
fetch('/installrmm', { fetch('/installrmm', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ installRMMCommand, UID, Name }) body: JSON.stringify(payload)
}); })
.then(response => response.text())
.then(data => appendLog(data, "green"))
.catch(error => appendLog(`Error: ${error.message}`, "red"));
appendLog("Datto RMM installation triggered...", "cyan");
} }
if (setSVSPowerplan.checked) { if (setSVSPowerplan) {
fetch('/installSVSPowerplan', { method: 'GET' }); fetch('/installSVSPowerplan', { method: 'GET' });
appendLog("Setting SVS Powerplan", "cyan"); appendLog("Setting SVS Powerplan...", "cyan");
} }
if (installSVSMSPModule.checked) { if (installCyberQP) {
fetch('/installSVSMSPModule', { method: 'GET' });
appendLog("Installing CyberQP", "cyan");
}
if (installCyberQP.checked) {
fetch('/installCyberQP', { method: 'GET' }); fetch('/installCyberQP', { method: 'GET' });
appendLog("Installing CyberQP", "cyan"); appendLog("Installing CyberQP...", "cyan");
} }
if (installSplashtop.checked) {
if (installSplashtop) {
fetch('/installSplashtop', { method: 'GET' }); fetch('/installSplashtop', { method: 'GET' });
appendLog("Installing Splashtop", "cyan"); appendLog("Installing Splashtop...", "cyan");
} }
if (installSVSHelpDesk.checked) {
if (installSVSHelpDesk) {
fetch('/installSVSHelpDesk', { method: 'GET' }); fetch('/installSVSHelpDesk', { method: 'GET' });
appendLog("Installing SVSHelpdesk", "cyan"); appendLog("Installing SVS HelpDesk...", "cyan");
} }
if (installSVSWatchtower.checked) {
if (installSVSWatchtower) {
fetch('/installSVSWatchtower', { method: 'GET' }); fetch('/installSVSWatchtower', { method: 'GET' });
appendLog("Installing SVSWatchtower", "cyan"); appendLog("Installing SVS Watchtower...", "cyan");
} }
if (installThreatLocker.checked) {
if (installThreatLocker) {
fetch('/installThreatLocker', { method: 'GET' }); fetch('/installThreatLocker', { method: 'GET' });
appendLog("Installing ThreatLocker", "cyan"); appendLog("Installing ThreatLocker...", "cyan");
} }
if (installRocketCyber.checked) {
if (installRocketCyber) {
fetch('/installRocketCyber', { method: 'GET' }); fetch('/installRocketCyber', { method: 'GET' });
appendLog("Installing RocketCyber", "cyan"); appendLog("Installing RocketCyber...", "cyan");
} }
} }
function endSession() { function endSession() {
appendLog("Session ended. Closing application...", "yellow"); appendLog("Session ended. Closing application...", "yellow");
fetch('/quit', { method: 'GET' }) fetch('/quit', { method: 'GET' })
@@ -868,35 +861,50 @@ 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()
$requestData = ConvertFrom-Json $body $requestData = ConvertFrom-Json $body
$installRMMCommand = $requestData.installRMMCommand
$UID = $requestData.UID $UID = $requestData.UID
$Name = $requestData.Name $Name = $requestData.Name
$dattoRMMOptions = $requestData.dattoRMMOptions
# Log the received command # Start building the Install-DattoRMM command
Write-LogHybrid -Message "Received command: $installRMMCommand for UID: $UID, Name: $Name" -Level "Info" $installCommand = "Install-DattoRMM -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$ApiSecretKey'"
# Add options based on the received data
if ($dattoRMMOptions -contains "inputVar") {
$installCommand += " -PushSiteVars"
}
if ($dattoRMMOptions -contains "rmm") {
$installCommand += " -InstallRMM"
}
if ($dattoRMMOptions -contains "exe") {
$installCommand += " -SaveCopy"
}
# Log and execute the command
Write-LogHybrid -Message "Executing DattoRMM install for UID: $UID, Name: $Name with command: $installCommand" -Level "Info"
try { try {
Invoke-Expression $installRMMCommand Invoke-Expression $installCommand
$responseString = "RMM install triggered successfully for UID: $UID, Name: $Name." $responseString = "DattoRMM installation triggered successfully for UID: $UID, Name: $Name."
} }
catch { catch {
$responseString = "Error triggering RMM install: $($_.Exception.Message)" $responseString = "Error triggering DattoRMM installation: $($_.Exception.Message)"
} }
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString) $buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
$response.ContentType = "text/plain" $response.ContentType = "text/plain"
$response.ContentLength64 = $buffer.Length $response.ContentLength64 = $buffer.Length
$response.OutputStream.Write($buffer, 0, $buffer.Length) $response.OutputStream.Write($buffer, 0, $buffer.Length)
$response.OutputStream.Close() $response.OutputStream.Close()
} }
} }