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
|
||||
|
||||
### 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
|
||||
if (-not (Get-Command -Name Write-Log -CommandType Function -ErrorAction SilentlyContinue)) {
|
||||
# If the Write-Log function doesn't exist, create the Write-LogHelper function
|
||||
@@ -687,80 +686,87 @@ function GetHtmlContent {
|
||||
|
||||
function triggerInstall() {
|
||||
const dropdown = document.getElementById('dattoRmmDropdown');
|
||||
const UID = dropdown.options[dropdown.selectedIndex]?.value || "";
|
||||
const Name = dropdown.options[dropdown.selectedIndex]?.text || "";
|
||||
const UID = dropdown.options[dropdown.selectedIndex].value;
|
||||
const Name = dropdown.options[dropdown.selectedIndex].text;
|
||||
|
||||
const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]').checked;
|
||||
const installCyberQP = document.querySelector('input[name="installCyberQP"]').checked;
|
||||
const installSplashtop = document.querySelector('input[name="installSplashtop"]').checked;
|
||||
const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]').checked;
|
||||
const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]').checked;
|
||||
const installThreatLocker = document.querySelector('input[name="installThreatLocker"]').checked;
|
||||
const installRocketCyber = document.querySelector('input[name="installRocketCyber"]').checked;
|
||||
const installDattoRMM = document.querySelector('input[name="installDattoRMM"]').checked;
|
||||
const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]');
|
||||
const installSVSMSPModule = document.querySelector('input[name="installSVSMSPModule"]');
|
||||
const installDattoRMM = document.querySelector('input[name="installDattoRMM"]');
|
||||
const installCyberQP = document.querySelector('input[name="installCyberQP"]');
|
||||
const installSplashtop = document.querySelector('input[name="installSplashtop"]');
|
||||
const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]');
|
||||
const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]');
|
||||
const installThreatLocker = document.querySelector('input[name="installThreatlocker"]');
|
||||
const installRocketCyber = document.querySelector('input[name="installRocketCyber"]');
|
||||
|
||||
if (installDattoRMM) {
|
||||
const dattoRMMOptions = Array.from(
|
||||
document.querySelectorAll('input[name="dattoRMMOption"]:checked')
|
||||
).map(option => option.value);
|
||||
if (installDattoRMM.checked) {
|
||||
const DattoRMMCheckbox = document.querySelectorAll('input[name="dattoRMMOption"]:checked');
|
||||
appendLog("Installing selected site RMM...", "cyan");
|
||||
|
||||
const payload = {
|
||||
UID,
|
||||
Name,
|
||||
dattoRMMOptions
|
||||
};
|
||||
const checkedValues = Array.from(DattoRMMCheckbox).map(c => c.value);
|
||||
|
||||
// Predefined PowerShell global variables passed into JavaScript
|
||||
// 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', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
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");
|
||||
body: JSON.stringify({ installRMMCommand, UID, Name })
|
||||
});
|
||||
}
|
||||
|
||||
if (setSVSPowerplan) {
|
||||
if (setSVSPowerplan.checked) {
|
||||
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' });
|
||||
appendLog("Installing CyberQP...", "cyan");
|
||||
appendLog("Installing CyberQP", "cyan");
|
||||
}
|
||||
|
||||
if (installSplashtop) {
|
||||
if (installSplashtop.checked) {
|
||||
fetch('/installSplashtop', { method: 'GET' });
|
||||
appendLog("Installing Splashtop...", "cyan");
|
||||
appendLog("Installing Splashtop", "cyan");
|
||||
}
|
||||
|
||||
if (installSVSHelpDesk) {
|
||||
if (installSVSHelpDesk.checked) {
|
||||
fetch('/installSVSHelpDesk', { method: 'GET' });
|
||||
appendLog("Installing SVS HelpDesk...", "cyan");
|
||||
appendLog("Installing SVSHelpdesk", "cyan");
|
||||
}
|
||||
|
||||
if (installSVSWatchtower) {
|
||||
if (installSVSWatchtower.checked) {
|
||||
fetch('/installSVSWatchtower', { method: 'GET' });
|
||||
appendLog("Installing SVS Watchtower...", "cyan");
|
||||
appendLog("Installing SVSWatchtower", "cyan");
|
||||
}
|
||||
|
||||
if (installThreatLocker) {
|
||||
if (installThreatLocker.checked) {
|
||||
fetch('/installThreatLocker', { method: 'GET' });
|
||||
appendLog("Installing ThreatLocker...", "cyan");
|
||||
appendLog("Installing ThreatLocker", "cyan");
|
||||
}
|
||||
|
||||
if (installRocketCyber) {
|
||||
if (installRocketCyber.checked) {
|
||||
fetch('/installRocketCyber', { method: 'GET' });
|
||||
appendLog("Installing RocketCyber...", "cyan");
|
||||
appendLog("Installing RocketCyber", "cyan");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function endSession() {
|
||||
appendLog("Session ended. Closing application...", "yellow");
|
||||
fetch('/quit', { method: 'GET' })
|
||||
@@ -861,43 +867,29 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
"/installrmm" {
|
||||
"/installrmm" {
|
||||
if ($request.HttpMethod -eq "POST") {
|
||||
$bodyStream = New-Object IO.StreamReader $request.InputStream
|
||||
$body = $bodyStream.ReadToEnd()
|
||||
$requestData = ConvertFrom-Json $body
|
||||
$bodyStream = New-Object IO.StreamReader $request.InputStream
|
||||
$body = $bodyStream.ReadToEnd()
|
||||
$requestData = ConvertFrom-Json $body
|
||||
|
||||
$installRMMCommand = $requestData.installRMMCommand
|
||||
$UID = $requestData.UID
|
||||
$Name = $requestData.Name
|
||||
$dattoRMMOptions = $requestData.dattoRMMOptions
|
||||
|
||||
# Start building the Install-DattoRMM command
|
||||
$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"
|
||||
# Log the received command
|
||||
Write-LogHybrid -Message "Received command: $installRMMCommand for UID: $UID, Name: $Name" -Level "Info"
|
||||
|
||||
try {
|
||||
Invoke-Expression $installCommand
|
||||
$responseString = "DattoRMM installation triggered successfully for UID: $UID, Name: $Name."
|
||||
Invoke-Expression $installRMMCommand
|
||||
$responseString = "RMM install triggered successfully for UID: $UID, Name: $Name."
|
||||
}
|
||||
catch {
|
||||
$responseString = "Error triggering DattoRMM installation: $($_.Exception.Message)"
|
||||
$responseString = "Error triggering RMM install: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
||||
$response.ContentType = "text/plain"
|
||||
$response.ContentType = "text/plain"
|
||||
$response.ContentLength64 = $buffer.Length
|
||||
$response.OutputStream.Write($buffer, 0, $buffer.Length)
|
||||
$response.OutputStream.Close()
|
||||
@@ -909,7 +901,6 @@ try {
|
||||
|
||||
|
||||
|
||||
|
||||
"/setSVSPowerplan" {
|
||||
if ($request.HttpMethod -eq "GET") {
|
||||
Set-SVSPowerPlan
|
||||
|
||||
Reference in New Issue
Block a user