Update SVSTaskGate.ps1
This commit is contained in:
149
SVSTaskGate.ps1
149
SVSTaskGate.ps1
@@ -1,3 +1,7 @@
|
|||||||
|
$global:ApiUrl
|
||||||
|
$global:ApiKey
|
||||||
|
$global:ApiSecretKey
|
||||||
|
|
||||||
### at this point we need to get the checkbox working again
|
### at this point we need to get the checkbox working again
|
||||||
|
|
||||||
### add tweek to set default provider, add to toolkit?
|
### add tweek to set default provider, add to toolkit?
|
||||||
@@ -12,11 +16,6 @@ if (-not $Global:LogCache -or -not ($Global:LogCache -is [System.Collections.Arr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$global:ApiUrl = "https://example-api-url.com"
|
|
||||||
$global:ApiKey = "your-api-key-here"
|
|
||||||
$global:ApiSecretKey = "your-secret-key-here"
|
|
||||||
|
|
||||||
|
|
||||||
# Check if the Write-Log function exists
|
# Check if the Write-Log function exists
|
||||||
if (-not (Get-Command -Name Write-Log -CommandType Function -ErrorAction SilentlyContinue)) {
|
if (-not (Get-Command -Name Write-Log -CommandType Function -ErrorAction SilentlyContinue)) {
|
||||||
# If the Write-Log function doesn't exist, create the Write-LogHelper function
|
# If the Write-Log function doesn't exist, create the Write-LogHelper function
|
||||||
@@ -687,80 +686,87 @@ 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"]').checked;
|
const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]');
|
||||||
const installCyberQP = document.querySelector('input[name="installCyberQP"]').checked;
|
const installSVSMSPModule = document.querySelector('input[name="installSVSMSPModule"]');
|
||||||
const installSplashtop = document.querySelector('input[name="installSplashtop"]').checked;
|
const installDattoRMM = document.querySelector('input[name="installDattoRMM"]');
|
||||||
const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]').checked;
|
const installCyberQP = document.querySelector('input[name="installCyberQP"]');
|
||||||
const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]').checked;
|
const installSplashtop = document.querySelector('input[name="installSplashtop"]');
|
||||||
const installThreatLocker = document.querySelector('input[name="installThreatLocker"]').checked;
|
const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]');
|
||||||
const installRocketCyber = document.querySelector('input[name="installRocketCyber"]').checked;
|
const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]');
|
||||||
const installDattoRMM = document.querySelector('input[name="installDattoRMM"]').checked;
|
const installThreatLocker = document.querySelector('input[name="installThreatlocker"]');
|
||||||
|
const installRocketCyber = document.querySelector('input[name="installRocketCyber"]');
|
||||||
|
|
||||||
if (installDattoRMM) {
|
if (installDattoRMM.checked) {
|
||||||
const dattoRMMOptions = Array.from(
|
const DattoRMMCheckbox = document.querySelectorAll('input[name="dattoRMMOption"]:checked');
|
||||||
document.querySelectorAll('input[name="dattoRMMOption"]:checked')
|
appendLog("Installing selected site RMM...", "cyan");
|
||||||
).map(option => option.value);
|
|
||||||
|
|
||||||
const payload = {
|
const checkedValues = Array.from(DattoRMMCheckbox).map(c => c.value);
|
||||||
UID,
|
|
||||||
Name,
|
// Predefined PowerShell global variables passed into JavaScript
|
||||||
dattoRMMOptions
|
// const ApiUrl = "$global:ApiUrl";
|
||||||
};
|
// 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(payload)
|
body: JSON.stringify({ installRMMCommand, UID, Name })
|
||||||
})
|
});
|
||||||
.then(response => response.text())
|
|
||||||
.then(data => appendLog(data, "green"))
|
|
||||||
.catch(error => appendLog(`Error: ${error.message}`, "red"));
|
|
||||||
|
|
||||||
appendLog("Datto RMM installation triggered...", "cyan");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setSVSPowerplan) {
|
if (setSVSPowerplan.checked) {
|
||||||
fetch('/installSVSPowerplan', { method: 'GET' });
|
fetch('/installSVSPowerplan', { method: 'GET' });
|
||||||
appendLog("Setting SVS Powerplan...", "cyan");
|
appendLog("Setting SVS Powerplan", "cyan");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installCyberQP) {
|
if (installSVSMSPModule.checked) {
|
||||||
|
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 SVS HelpDesk...", "cyan");
|
appendLog("Installing SVSHelpdesk", "cyan");
|
||||||
}
|
}
|
||||||
|
if (installSVSWatchtower.checked) {
|
||||||
if (installSVSWatchtower) {
|
|
||||||
fetch('/installSVSWatchtower', { method: 'GET' });
|
fetch('/installSVSWatchtower', { method: 'GET' });
|
||||||
appendLog("Installing SVS Watchtower...", "cyan");
|
appendLog("Installing SVSWatchtower", "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' })
|
||||||
@@ -861,43 +867,29 @@ 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
|
|
||||||
|
|
||||||
# Start building the Install-DattoRMM command
|
# Log the received command
|
||||||
$installCommand = "Install-DattoRMM -ApiUrl '$ApiUrl' -ApiKey '$ApiKey' -ApiSecretKey '$ApiSecretKey'"
|
Write-LogHybrid -Message "Received command: $installRMMCommand for UID: $UID, Name: $Name" -Level "Info"
|
||||||
|
|
||||||
# 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 $installCommand
|
Invoke-Expression $installRMMCommand
|
||||||
$responseString = "DattoRMM installation triggered successfully for UID: $UID, Name: $Name."
|
$responseString = "RMM install triggered successfully for UID: $UID, Name: $Name."
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
$responseString = "Error triggering DattoRMM installation: $($_.Exception.Message)"
|
$responseString = "Error triggering RMM install: $($_.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()
|
||||||
@@ -909,7 +901,6 @@ try {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"/setSVSPowerplan" {
|
"/setSVSPowerplan" {
|
||||||
if ($request.HttpMethod -eq "GET") {
|
if ($request.HttpMethod -eq "GET") {
|
||||||
Set-SVSPowerPlan
|
Set-SVSPowerPlan
|
||||||
|
|||||||
Reference in New Issue
Block a user