Update TGBeta.ps1
This commit is contained in:
181
TGBeta.ps1
181
TGBeta.ps1
@@ -12,6 +12,17 @@
|
|||||||
### need to have the fetch button check if Install-DattoRMM function exist if not run the build in helpder function to fetch sites
|
### need to have the fetch button check if Install-DattoRMM function exist if not run the build in helpder function to fetch sites
|
||||||
### need to move the tweaks to the tweeks tab
|
### need to move the tweaks to the tweeks tab
|
||||||
|
|
||||||
|
### To Modify as of January 27 2025
|
||||||
|
|
||||||
|
### let's start thinking about the write-log -TaskCategory "On-boarding" or "Off-boarding"
|
||||||
|
### need RGB color codes form john, once we picked the RGBA colors
|
||||||
|
### add the .net silent install tweaks to toolkit
|
||||||
|
### for the reg tweak need to do/undo function maybe it should have it own check box list
|
||||||
|
### added offboard check boxes for dattormm, dattodeb, rocketcyber, cyberQP, SVSHelpdesk and Splashtop
|
||||||
|
### for the offboarding button, we need to fix the uninstall-svsmsp module
|
||||||
|
### need to fix path in the uninstall-DattoEDR -
|
||||||
|
####### ❌ [Error] [GeneralTask] Uninstallation command 'C:\Program Files\Infocyte\Agent\agent.exe' not found. (Event ID: 3000) - bad path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Write-Log
|
#region Write-Log
|
||||||
@@ -738,12 +749,9 @@ function GetHtmlContent {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- tweaks Tab -->
|
||||||
<div id="tweaksTab" class="tab-content inactive">
|
<div id="tweaksTab" class="tab-content inactive">
|
||||||
<h2>Tweaks</h2>
|
<h2>Tweaks</h2>
|
||||||
<div class="columns-container">
|
|
||||||
<!-- Column 1 -->
|
|
||||||
<div class="column" id="tweaksColumn1">
|
|
||||||
<h3>System Optimizations</h3>
|
|
||||||
<div class="checkbox-group">
|
<div class="checkbox-group">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="selectAllTweaksCheckbox" onclick="toggleTweaksCheckboxes(this)">
|
<input type="checkbox" id="selectAllTweaksCheckbox" onclick="toggleTweaksCheckboxes(this)">
|
||||||
@@ -753,58 +761,23 @@ function GetHtmlContent {
|
|||||||
<input type="checkbox" name="setedgedefaultsearch" id="setedgedefaultsearchCheckbox">
|
<input type="checkbox" name="setedgedefaultsearch" id="setedgedefaultsearchCheckbox">
|
||||||
Set Edge Default Search Engine
|
Set Edge Default Search Engine
|
||||||
</label>
|
</label>
|
||||||
<label>
|
|
||||||
<input type="checkbox" name="setWindowsPerformance" id="setWindowsPerformanceCheckbox">
|
|
||||||
Optimize Windows Performance
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" name="stopUnnecessaryServices" id="stopUnnecessaryServicesCheckbox">
|
|
||||||
Stop Unnecessary Services
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Column 2 -->
|
|
||||||
<div class="column" id="tweaksColumn2">
|
|
||||||
<h3>Additional Tweaks</h3>
|
|
||||||
<div class="checkbox-group">
|
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="disableAnimations" id="disableAnimationsCheckbox">
|
<input type="checkbox" name="disableAnimations" id="disableAnimationsCheckbox">
|
||||||
Disable Animations
|
Disable Animations
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="optimizePerformance" id="optimizePerformanceCheckbox">
|
<input type="checkbox" name="optimizePerformance" id="optimizePerformanceCheckbox">
|
||||||
Optimize Application Performance
|
Optimize Performance
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="increaseFontSize" id="increaseFontSizeCheckbox">
|
<input type="checkbox" name="increaseFontSize" id="increaseFontSizeCheckbox">
|
||||||
Increase Font Size
|
Increase Font Size
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Column 3 -->
|
|
||||||
<div class="column" id="tweaksColumn3">
|
|
||||||
<h3>Miscellaneous</h3>
|
|
||||||
<div class="checkbox-group">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" name="enableDarkMode" id="enableDarkModeCheckbox">
|
|
||||||
Enable Dark Mode
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" name="clearTempFiles" id="clearTempFilesCheckbox">
|
|
||||||
Clear Temporary Files
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Apply Tweaks Button -->
|
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<button class="install-button" onclick="triggerTweaks()">Apply Tweaks</button>
|
<button class="install-button" onclick="triggerTweaks()">Tweaks</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Shared Exit Button -->
|
<!-- Shared Exit Button -->
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<button class="exit-button" onclick="endSession()">Exit</button>
|
<button class="exit-button" onclick="endSession()">Exit</button>
|
||||||
@@ -961,55 +934,13 @@ function GetHtmlContent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function triggerTweaks() {
|
function triggerTweaks() {
|
||||||
// Gather all selected tweaks
|
const setedgedefaultsearch = document.querySelector('input[name="setedgedefaultsearch"]');
|
||||||
const selectedTweaks = [];
|
|
||||||
document.querySelectorAll('#tweaksTab input[type="checkbox"]').forEach(checkbox => {
|
|
||||||
if (checkbox.checked) {
|
|
||||||
selectedTweaks.push(checkbox.name); // Use 'name' as the identifier
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (selectedTweaks.length === 0) {
|
|
||||||
appendLog("No tweaks selected. Please select at least one tweak.", "red");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send selected tweaks to the backend
|
|
||||||
fetch('/runTweaks', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ tweaks: selectedTweaks })
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to apply tweaks: ${response.statusText}`);
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
// Log successes and errors
|
|
||||||
if (data.Success && data.Success.length > 0) {
|
|
||||||
data.Success.forEach(tweak => appendLog(`Successfully applied: ${tweak}`, "green"));
|
|
||||||
}
|
|
||||||
if (data.Errors && data.Errors.length > 0) {
|
|
||||||
data.Errors.forEach(error => appendLog(`Error: ${error}`, "red"));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
appendLog(`Unexpected error: ${error.message}`, "red");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendLog(message, color = "white") {
|
|
||||||
const log = document.createElement('p');
|
|
||||||
log.style.color = color;
|
|
||||||
log.textContent = message;
|
|
||||||
document.getElementById('logArea').appendChild(log);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
if (setedgedefaultsearch.checked) {
|
||||||
|
fetch('/setedgedefaultsearch', { method: 'GET' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function toggleDattoRMMOptions() {
|
function toggleDattoRMMOptions() {
|
||||||
@@ -1031,22 +962,14 @@ function GetHtmlContent {
|
|||||||
|
|
||||||
tabButtons.forEach(button => {
|
tabButtons.forEach(button => {
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
console.log(`Tab button clicked: ${button.dataset.tab}`); // Log which tab button was clicked
|
|
||||||
tabButtons.forEach(btn => {
|
tabButtons.forEach(btn => {
|
||||||
btn.classList.remove('active');
|
btn.classList.remove('active');
|
||||||
btn.setAttribute('aria-expanded', 'false');
|
btn.setAttribute('aria-expanded', 'false');
|
||||||
});
|
});
|
||||||
tabContents.forEach(tab => tab.classList.remove('active'));
|
tabContents.forEach(tab => tab.classList.remove('active'));
|
||||||
|
|
||||||
button.classList.add('active');
|
button.classList.add('active');
|
||||||
button.setAttribute('aria-expanded', 'true');
|
button.setAttribute('aria-expanded', 'true');
|
||||||
const targetTab = document.getElementById(button.dataset.tab);
|
document.getElementById(button.dataset.tab).classList.add('active');
|
||||||
console.log(`Activating tab: ${button.dataset.tab}`);
|
|
||||||
if (targetTab) {
|
|
||||||
targetTab.classList.add('active');
|
|
||||||
} else {
|
|
||||||
console.error(`Tab not found: ${button.dataset.tab}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1729,63 +1652,46 @@ try {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 3: Define Lookup Table for Tweaks
|
# Step 3: Run Selected Tweaks
|
||||||
$tweakActions = @{
|
|
||||||
"setWindowsPerformanceCheckbox" = { .\Set-WindowsPerformance.ps1 }
|
|
||||||
"stopUnnecessaryServicesCheckbox" = { .\Stop-UnnecessaryServices.ps1 }
|
|
||||||
"setedgedefaultsearchCheckbox" = { Set-EdgeDefaultSearchEngine }
|
|
||||||
"disableAnimationsCheckbox" = { Disable-Animations }
|
|
||||||
"optimizePerformanceCheckbox" = { Optimize-Performance }
|
|
||||||
"increaseFontSizeCheckbox" = { Increase-FontSize }
|
|
||||||
"enableDarkModeCheckbox" = { Enable-DarkMode }
|
|
||||||
"clearTempFilesCheckbox" = { Clear-TempFiles }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Step 4: Process Each Selected Tweak
|
|
||||||
$tweaksProcessed = @()
|
|
||||||
$errors = @()
|
|
||||||
foreach ($tweak in $tweaks) {
|
foreach ($tweak in $tweaks) {
|
||||||
if ($tweakActions[$tweak]) {
|
switch ($tweak) {
|
||||||
try {
|
"enableDarkModeCheckbox" {
|
||||||
# Execute the tweak function or script
|
Write-LogHybrid -Message "Running tweak: Set Edge Default Search Engine" -Level "Info"
|
||||||
$tweakActions[$tweak].Invoke()
|
Set-EdgeDefaultSearchEngine
|
||||||
Write-LogHybrid -Message "Tweak '$tweak' applied successfully." -Level "Info"
|
|
||||||
$tweaksProcessed += $tweak
|
|
||||||
} catch {
|
|
||||||
# Log and collect errors for this tweak
|
|
||||||
$errorMessage = "Failed to apply tweak '$tweak': $($_.Exception.Message)"
|
|
||||||
Write-LogHybrid -Message $errorMessage -Level "Error"
|
|
||||||
$errors += $errorMessage
|
|
||||||
}
|
}
|
||||||
} else {
|
"disableAnimationsCheckbox" {
|
||||||
# Handle unknown tweaks
|
Write-LogHybrid -Message "Running tweak: Disable Animations" -Level "Info"
|
||||||
|
#Disable-Animations
|
||||||
|
}
|
||||||
|
"optimizePerformanceCheckbox" {
|
||||||
|
Write-LogHybrid -Message "Running tweak: Optimize Performance" -Level "Info"
|
||||||
|
#Optimize-Performance
|
||||||
|
}
|
||||||
|
"increaseFontSizeCheckbox" {
|
||||||
|
Write-LogHybrid -Message "Running tweak: Increase Font Size" -Level "Info"
|
||||||
|
#Increase-FontSize
|
||||||
|
}
|
||||||
|
default {
|
||||||
Write-LogHybrid -Message "Unknown tweak: $tweak" -Level "Warning"
|
Write-LogHybrid -Message "Unknown tweak: $tweak" -Level "Warning"
|
||||||
$errors += "Unknown tweak: $tweak"
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 5: Return Summary of Results
|
# Step 4: Return Success Response
|
||||||
$responseData = @{
|
$responseString = "Selected tweaks executed successfully."
|
||||||
Success = $tweaksProcessed
|
|
||||||
Errors = $errors
|
|
||||||
}
|
|
||||||
$responseString = $responseData | ConvertTo-Json -Depth 2
|
|
||||||
$response.StatusCode = 200
|
$response.StatusCode = 200
|
||||||
} catch {
|
} catch {
|
||||||
# Handle General Errors
|
|
||||||
$responseString = "Error processing tweaks: $($_.Exception.Message)"
|
$responseString = "Error processing tweaks: $($_.Exception.Message)"
|
||||||
Write-LogHybrid -Message $responseString -Level "Error"
|
|
||||||
$response.StatusCode = 500
|
$response.StatusCode = 500
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 6: Send Response
|
# Send the Response
|
||||||
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
||||||
$response.ContentType = "application/json"
|
$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()
|
||||||
} else {
|
} else {
|
||||||
# Handle Unsupported HTTP Methods
|
|
||||||
$responseString = "Method not allowed. Use POST."
|
$responseString = "Method not allowed. Use POST."
|
||||||
$response.StatusCode = 405
|
$response.StatusCode = 405
|
||||||
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
$buffer = [System.Text.Encoding]::UTF8.GetBytes($responseString)
|
||||||
@@ -1795,7 +1701,6 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# 4) NEW ROUTE: /getLogs
|
# 4) NEW ROUTE: /getLogs
|
||||||
# Returns $Global:LogCache as JSON for the polling function
|
# Returns $Global:LogCache as JSON for the polling function
|
||||||
|
|||||||
Reference in New Issue
Block a user