diff --git a/testTaskGate.ps1 b/testTaskGate.ps1 index 0da32b9..0035b32 100644 --- a/testTaskGate.ps1 +++ b/testTaskGate.ps1 @@ -1,338 +1,172 @@ -###-----------------------------------------------------------------------------### -### SVS TaskGate Launcher -###-----------------------------------------------------------------------------### +# SVS TaskGate: Self-contained PowerShell Task Runner UI (All-in-One Script) -# 1) GLOBAL LOG CACHE -if (-not $Global:LogCache -or -not ($Global:LogCache -is [System.Collections.ArrayList])) { - $Global:LogCache = New-Object System.Collections.ArrayList +# ----- 1. TASK REGISTRY ----- +$TaskRegistry = @{ + Onboarding = @( + @{ Key = "installSVSMSP"; Label = "Install SVSMSP Module"; Function = "Install-SVSMSP" } + @{ Key = "installDattoRMM"; Label = "Install DattoRMM"; Function = "Install-DattoRMM" } + @{ Key = "installCyberQP"; Label = "Install CyberQP"; Function = "Install-CyberQP" } + ) + Offboarding = @( + @{ Key = "uninstallSVSMSP"; Label = "Uninstall SVSMSP Module"; Function = "Uninstall-SVSMSP" } + @{ Key = "uninstallDattoRMM"; Label = "Uninstall DattoRMM"; Function = "Uninstall-DattoRMM" } + @{ Key = "uninstallCyberQP"; Label = "Uninstall CyberQP"; Function = "Uninstall-CyberQP" } + ) + Tweaks = @( + @{ Key = "setPowerPlan"; Label = "Set Power Plan"; Function = "Set-SVSPowerPlan" } + @{ Key = "enableBitLocker"; Label = "Enable BitLocker"; Function = "Enable-BitLocker" } + ) } -#region Write-LogHybrid -if (-not (Get-Command Write-Log -ErrorAction SilentlyContinue)) { - function Write-LogHelper { - param( - [string]$Message, - [ValidateSet("Info","Warning","Error","Success","General")] - [string]$Level = "Info", - [string]$TaskCategory = "GeneralTask", - [switch]$LogToEvent, - [string]$EventSource = "SVSMSP_Module", - [string]$EventLog = "Application" - ) - $EventID = switch($Level){ - "Info" {1000}; "Warning"{2000}; "Error"{3000}; "Success"{4000}; default{1000} - } - $Icon = switch($Level){ - "Info" { [char]0x1F4CB } - "Warning" { [char]0x26A0 } - "Error" { [char]0x274C } - "Success" { [char]0x2705 } - default { [char]0x1F4E6 } - } - $entry = [PSCustomObject]@{ - Timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") - Level = $Level - Message = "$Icon [$Level] [$TaskCategory] $Message (Event ID: $EventID)" - } - [void]$Global:LogCache.Add($entry) - if ($LogToEvent) { - try { - if (-not (Get-EventLog -LogName $EventLog -Source $EventSource -ErrorAction SilentlyContinue)) { - New-EventLog -LogName $EventLog -Source $EventSource -ErrorAction SilentlyContinue - } - Write-EventLog -LogName $EventLog -Source $EventSource ` - -EntryType $Level -EventId $EventID -Message $Message - } catch { - Write-Host "⚠ Failed writing to EventLog: $($_.Exception.Message)" -ForegroundColor Yellow - } - } - } - function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) - Write-LogHelper -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent - } -} else { - function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) - Write-Log -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent +# ----- 2. FUNCTION STUBS (Replace with real logic) ----- +function Install-SVSMSP { Write-Host "Installing SVSMSP Module..." } +function Install-DattoRMM { Write-Host "Installing DattoRMM..." } +function Install-CyberQP { Write-Host "Installing CyberQP..." } +function Uninstall-SVSMSP { Write-Host "Uninstalling SVSMSP Module..." } +function Uninstall-DattoRMM { Write-Host "Uninstalling DattoRMM..." } +function Uninstall-CyberQP { Write-Host "Uninstalling CyberQP..." } +function Set-SVSPowerPlan { Write-Host "Setting SVS Power Plan..." } +function Enable-BitLocker { Write-Host "Enabling BitLocker..." } + +# ----- 3. HTML UI GENERATOR ----- +function Get-TasksHtml($group) { + $html = "" + foreach ($task in $TaskRegistry[$group]) { + $html += "
`n" } + return $html } -Write-LogHybrid -Message "Starting SVS TaskGate" -Level Info -TaskCategory Startup -LogToEvent -#region Helpers for DattoRMM, LastPass, SVS Module… -# (Insert your existing Install-DattoRMM-Helper, LastPass and Install-SVSMSP functions here.) -#endregion - - -#region HTTP Listener Setup -$listener = New-Object System.Net.HttpListener -$listener.Prefixes.Add("http://localhost:8081/") -$listener.Start() -Write-LogHybrid -Message "Listener started on http://localhost:8081/" -Level Info -TaskCategory Listener -#endregion - - -#region HTML UI & CSS -function GetHtmlContent { -@" +$HtmlContent = @" - - SVS TaskGate - - - + + SVS TaskGate + - -
- SVS Logo -
- -
-