diff --git a/module/Samy.UI.ps1 b/module/Samy.UI.ps1 deleted file mode 100644 index 9108937..0000000 --- a/module/Samy.UI.ps1 +++ /dev/null @@ -1,348 +0,0 @@ -# Samy.UI.ps1 -# Task metadata and UI HTML generation - -# Global task definitions used by UI and headless offboard -$Global:SamyTasks = @( - # On-Boarding, left column - @{ Id='setSVSPowerplan'; Name='setSVSPowerplan'; Label='Set SVS Powerplan'; HandlerFn='Invoke-setSVSPowerPlan'; Page='onboard'; Column='left' }, - @{ Id='installSVSMSPModule'; Name='installSVSMSPModule'; Label='Install SVSMSP Module'; HandlerFn='Invoke-InstallSVSMSP'; Page='onboard'; Column='left' }, - @{ Id='installCyberQP'; Name='installCyberQP'; Label='Install CyberQP'; HandlerFn='Invoke-InstallCyberQP'; Page='onboard'; Column='left' }, - @{ Id='installHelpDesk'; Name='installHelpDesk'; Label='Install HelpDesk'; HandlerFn='Invoke-InstallHelpDesk'; Page='onboard'; Column='left' }, - @{ Id='installThreatLocker'; Name='installThreatLocker'; Label='Install ThreatLocker'; HandlerFn='Invoke-InstallThreatLocker'; Page='onboard'; Column='left' }, - @{ Id='installRocketCyber'; Name='installRocketCyber'; Label='Install RocketCyber'; HandlerFn='Invoke-InstallRocketCyber'; Page='onboard'; Column='left' }, - @{ Id='installDattoRMM'; Name='installDattoRMM'; Label='Install DattoRMM'; HandlerFn='Invoke-InstallDattoRMM'; Page='onboard'; Column='left'; - SubOptions= @( - @{ Value='inputVar'; Label='Copy Site Variables' }, - @{ Value='rmm'; Label='Install RMM Agent' }, - @{ Value='exe'; Label='Download Executable' } - ) - }, - - # On-Boarding, right column - @{ Id='enableBitLocker'; Name='EnableBitLocker'; Label='Enable BitLocker'; HandlerFn='Set-SVSBitLocker'; Page='onboard'; Column='right' }, - @{ Id='setEdgeDefaultSearch'; Name='setedgedefaultsearch'; Label='Set Edge Default Search'; Tooltip='Will configure Edge to use Google as default search provider'; HandlerFn='Invoke-SetEdgeDefaultSearchEngine'; Page='onboard'; Column='right' }, - - # Off-Boarding - @{ Id='offUninstallCyberQP'; Name='offUninstallCyberQP'; Label='Uninstall CyberQP'; HandlerFn='Invoke-UninstallCyberQP'; Page='offboard' }, - @{ Id='offUninstallHelpDesk'; Name='offUninstallHelpDesk'; Label='Uninstall HelpDesk'; HandlerFn='Invoke-UninstallHelpDesk'; Page='offboard' }, - @{ Id='offUninstallThreatLocker'; Name='offUninstallThreatLocker'; Label='Uninstall ThreatLocker'; HandlerFn='Invoke-UninstallThreatLocker'; Page='offboard' }, - @{ Id='offUninstallRocketCyber'; Name='offUninstallRocketCyber'; Label='Uninstall RocketCyber'; HandlerFn='Invoke-UninstallRocketCyber'; Page='offboard' }, - @{ Id='offCleanupSVSMSPModule'; Name='offCleanupSVSMSPModule'; Label='Cleanup SVSMSP Toolkit'; HandlerFn='Invoke-CleanupSVSMSP'; Page='offboard' }, - - # Tweaks - @{ Id='disableAnimations'; Name='disableAnimations'; Label='Disable Animations'; HandlerFn='Disable-Animations'; Page='tweaks' }, - - # SVS Apps - @{ Id='wingetLastpass'; Name='wingetLastpass'; Label='LastPass Desktop App'; HandlerFn='Install-WingetLastPass'; Page='SVSApps' }, - @{ Id='wingetChrome'; Name='wingetChrome'; Label='Google Chrome'; HandlerFn='Invoke-InstallChrome'; Page='SVSApps' }, - @{ Id='wingetAcrobat'; Name='wingetAcrobat'; Label='Adobe Acrobat Reader (64-bit)'; HandlerFn='Invoke-InstallAcrobat'; Page='SVSApps' } -) - -Write-LogHybrid "Tasks by page: onboard=$( - ($Global:SamyTasks | Where-Object Page -eq 'onboard').Count -) offboard=$( - ($Global:SamyTasks | Where-Object Page -eq 'offboard').Count -) tweaks=$( - ($Global:SamyTasks | Where-Object Page -eq 'tweaks').Count -) apps=$( - ($Global:SamyTasks | Where-Object Page -eq 'SVSApps').Count -)" Info UI -LogToEvent - -function Publish-Checkboxes { - param( - [Parameter(Mandatory)][string]$Page, - [string]$Column - ) - - $tasks = $Global:SamyTasks | Where-Object Page -EQ $Page - - if (-not [string]::IsNullOrEmpty($Column)) { - $tasks = $tasks | Where-Object Column -EQ $Column - } - - ( - $tasks | - ForEach-Object { - $taskId = $_.Id - $tooltip = if ($_.PSObject.Properties.Name -contains 'Tooltip' -and $_.Tooltip) { - " title='$($_.Tooltip)'" - } else { '' } - - $html = " $($_.Label)" - - if ($_.SubOptions) { - $subHtml = ( - $_.SubOptions | - ForEach-Object { - "" - } - ) -join "`n" - - $html += @" - -"@ - } - - $html - } - ) -join "`n" -} - -function Get-ModuleVersionHtml { - $mod = Get-Module -ListAvailable -Name SVSMSP | Sort-Object Version -Descending | Select-Object -First 1 - - $branchDisplay = switch ($Script:SamyBranch.ToLower()) { - 'main' { 'Main / Stable' } - 'beta' { 'Beta' } - default { $Script:SamyBranch } - } - - if ($mod) { - return "
-Module Version: $($mod.Version)
-UI Branch: $branchDisplay -
" - } - - return "
SVSMSP_Module not found
" -} - -function Get-RemoteText { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true)][string]$Url - ) - - try { - $resp = Invoke-WebRequest -Uri $Url -UseBasicParsing -ErrorAction Stop - return $resp.Content - } - catch { - Write-LogHybrid "Get-RemoteText failed for ${Url}: $($_.Exception.Message)" Warning UI -LogToEvent - return "" - } -} - -function Get-UIHtml { - param([string]$Page = 'onboard') - if (-not $Page) { $Page = 'onboard' } - - $onboardLeft = Publish-Checkboxes -Page 'onboard' -Column 'left' - $onboardRight = Publish-Checkboxes -Page 'onboard' -Column 'right' - $offboard = Publish-Checkboxes -Page 'offboard' -Column '' - $tweaks = Publish-Checkboxes -Page 'tweaks' -Column '' - $apps = Publish-Checkboxes -Page 'SVSApps' -Column '' - - $tasksJsAll = ( - $Global:SamyTasks | ForEach-Object { - " { id: '$($_.Id)', handler: '/$($_.Name)', label: '$($_.Label)' }" - } - ) -join ",`n" - - $cssContent = Get-RemoteText -Url $Script:SamyCssUrl - $jsContent = Get-RemoteText -Url $Script:SamyJsUrl - - if ($cssContent) { - $pattern = 'background-image:\s*url\("SAMY\.png"\);?' - $replacement = "background-image: url('$Script:SamyBgLogoUrl');" - $cssContent = [regex]::Replace($cssContent, $pattern, $replacement) - } - - $htmlTemplate = @" - - - - - -Script Automation Monkey - - - - -
-
- SVS Logo - {{moduleVersion}} -
- -
- Script Automation Monkey (Yeah!) -
- -
-
- -
- -
-
-

On-Boarding

-

This new deployment method ensures everything is successfully deployed with greater ease!

- -
-
-

SVSMSP Stack

- - {{onboardLeftColumn}} -
-
-

Optional

- - {{onboardRightColumn}} - -
- -
- - -
-
- - - - -
- -
-

Off-Boarding

-
-
-

Remove Stack

- - {{offboardCheckboxes}} -
-
-
- -
-

Tweaks

-
-
-

Tweaks

- {{tweaksCheckboxes}} -
-
-
- -
-

SVS APPs

-
-
-

Applications

- {{appsCheckboxes}} -
-
-
- -
-

Devices

-

Manage printers and other client devices.

- -
- -
- - -
-
- - - - -
-
-
- - - - - -
- - -
- - - -"@ - - $html = $htmlTemplate - $html = $html.Replace('{{moduleVersion}}', (Get-ModuleVersionHtml)) - $html = $html.Replace('{{onboardLeftColumn}}', $onboardLeft) - $html = $html.Replace('{{onboardRightColumn}}', $onboardRight) - $html = $html.Replace('{{offboardCheckboxes}}', $offboard) - $html = $html.Replace('{{tweaksCheckboxes}}', $tweaks) - $html = $html.Replace('{{appsCheckboxes}}', $apps) - $html = $html.Replace('{{tasksJsAll}}', $tasksJsAll) - $html = $html.Replace('{{defaultPage}}', $Page) - - return $html -}