Update TGBeta.ps1
This commit is contained in:
108
TGBeta.ps1
108
TGBeta.ps1
@@ -817,37 +817,56 @@ function GetHtmlContent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function toggleOffboardCheckboxes(selectAllCheckbox) {
|
function toggleOffboardCheckboxes(selectAllCheckbox) {
|
||||||
// Get all checkboxes inside the offboardTab container
|
const checkboxes = document.querySelectorAll('#offboardTab input[type="checkbox"]:not(#selectAllOffboardCheckbox)');
|
||||||
const checkboxes = document
|
|
||||||
.getElementById('offboardTab')
|
|
||||||
.querySelectorAll('input[type="checkbox"]:not(#selectAllOffboardCheckbox)');
|
|
||||||
|
|
||||||
// Set the checked state of all checkboxes to match the "Select All" checkbox
|
|
||||||
checkboxes.forEach(checkbox => {
|
checkboxes.forEach(checkbox => {
|
||||||
checkbox.checked = selectAllCheckbox.checked;
|
checkbox.checked = selectAllCheckbox.checked;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateSelectAllOffboard() {
|
function updateSelectAllOffboard() {
|
||||||
const selectAllCheckbox = document.getElementById('selectAllOffboardCheckbox');
|
const selectAllCheckbox = document.getElementById('selectAllOffboardCheckbox');
|
||||||
const checkboxes = document
|
const checkboxes = document.querySelectorAll('#offboardTab input[type="checkbox"]:not(#selectAllOffboardCheckbox)');
|
||||||
.getElementById('offboardTab')
|
|
||||||
.querySelectorAll('input[type="checkbox"]:not(#selectAllOffboardCheckbox)');
|
|
||||||
|
|
||||||
// If any checkbox is unchecked, uncheck "Select All"
|
|
||||||
selectAllCheckbox.checked = Array.from(checkboxes).every(checkbox => checkbox.checked);
|
selectAllCheckbox.checked = Array.from(checkboxes).every(checkbox => checkbox.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach the updateSelectAllOffboard function to all individual checkboxes
|
|
||||||
document.querySelectorAll('#offboardTab input[type="checkbox"]:not(#selectAllOffboardCheckbox)').forEach(checkbox => {
|
document.querySelectorAll('#offboardTab input[type="checkbox"]:not(#selectAllOffboardCheckbox)').forEach(checkbox => {
|
||||||
checkbox.addEventListener('change', updateSelectAllOffboard);
|
checkbox.addEventListener('change', updateSelectAllOffboard);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function triggerOffboard() {
|
function triggerOffboard() {
|
||||||
appendLog("testeteteteteteet")
|
const checkboxes = document.querySelectorAll('#offboardTab input[type="checkbox"]:not(#selectAllOffboardCheckbox)');
|
||||||
|
const selectedTasks = Array.from(checkboxes)
|
||||||
|
.filter(checkbox => checkbox.checked)
|
||||||
|
.map(checkbox => checkbox.name);
|
||||||
|
|
||||||
|
if (selectedTasks.length === 0) {
|
||||||
|
appendLog("Please select at least one offboarding task.", "red");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
appendLog("Starting offboarding tasks...", "yellow");
|
||||||
|
|
||||||
|
fetch('/offboard', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ SelectedTasks: selectedTasks })
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Failed to execute offboarding tasks.');
|
||||||
|
}
|
||||||
|
return response.text();
|
||||||
|
})
|
||||||
|
.then(message => {
|
||||||
|
appendLog(message, "green");
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
appendLog("Error: " + error.message, "red");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function toggleTweaksCheckboxes(selectAllCheckbox) {
|
function toggleTweaksCheckboxes(selectAllCheckbox) {
|
||||||
// Get all checkboxes inside the tweaksTab container
|
// Get all checkboxes inside the tweaksTab container
|
||||||
const checkboxes = document
|
const checkboxes = document
|
||||||
@@ -1474,6 +1493,67 @@ try {
|
|||||||
$response.OutputStream.Close()
|
$response.OutputStream.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"/offboard" {
|
||||||
|
if ($request.HttpMethod -eq "POST") {
|
||||||
|
try {
|
||||||
|
# Read the Request Body
|
||||||
|
$bodyStream = New-Object IO.StreamReader $request.InputStream
|
||||||
|
$body = $bodyStream.ReadToEnd()
|
||||||
|
$requestData = ConvertFrom-Json $body
|
||||||
|
|
||||||
|
$selectedTasks = $requestData.SelectedTasks
|
||||||
|
|
||||||
|
if (-not $selectedTasks -or $selectedTasks.Count -eq 0) {
|
||||||
|
$response.StatusCode = 400
|
||||||
|
$responseString = "Error: No offboarding tasks selected."
|
||||||
|
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
||||||
|
$response.OutputStream.Write($buffer, 0, $buffer.Length)
|
||||||
|
$response.OutputStream.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# Process each selected task
|
||||||
|
foreach ($task in $selectedTasks) {
|
||||||
|
switch ($task) {
|
||||||
|
"uninstallSVSMSPModule" { Uninstall-SVSMSP }
|
||||||
|
"uninstallThreatLocker" { Uninstall-ThreatLocker }
|
||||||
|
"uninstallCyberQP" { Uninstall-CyberQP }
|
||||||
|
"uninstallDattoEDR" { Uninstall-DattoEDR }
|
||||||
|
"uninstallDattoRMM" { Uninstall-DattoRMM }
|
||||||
|
"uninstallRocketCyber" { Uninstall-RocketCyber }
|
||||||
|
"uninstallSplashtop" { Uninstall-Splashtop }
|
||||||
|
"uninstallSVSHelpdesk" { Uninstall-SVSHelpdesk }
|
||||||
|
"uninstallSVSWatchtower" { Uninstall-SVSWatchtower }
|
||||||
|
default {
|
||||||
|
Write-LogHybrid -Message "Unknown task: $task" -Level "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return Success Response
|
||||||
|
$responseString = "Offboarding tasks executed successfully."
|
||||||
|
$response.StatusCode = 200
|
||||||
|
} catch {
|
||||||
|
$responseString = "Error processing offboarding tasks: $($_.Exception.Message)"
|
||||||
|
$response.StatusCode = 500
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the Response
|
||||||
|
$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()
|
||||||
|
} else {
|
||||||
|
$responseString = "Method not allowed. Use POST."
|
||||||
|
$response.StatusCode = 405
|
||||||
|
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
||||||
|
$response.OutputStream.Write($buffer, 0, $buffer.Length)
|
||||||
|
$response.OutputStream.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
"/runTweaks" {
|
"/runTweaks" {
|
||||||
if ($request.HttpMethod -eq "POST") {
|
if ($request.HttpMethod -eq "POST") {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user