Update StackMonkey_Beta.ps1

This commit is contained in:
2025-07-02 18:05:09 -04:00
parent 97666080a8
commit 20d398c57c

View File

@@ -1,11 +1,13 @@
#region changes to be done
<#
# seems like the command IS running without UI
# & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com').Content )) -N8nPassword 'Tndmeeisdwge!' -FetchSitesOnly
& ([ScriptBlock]::Create((iwr 'https://sm.svstools.com' -UseBasicParsing).Content )) -N8nPassword 'pwd' -SiteUID '' -SiteName '' -InstallRMM -PushSiteVars -SaveCopy
Need to pass the N8N variables to the "install-dattormm" in the toolkit
# and iwr sm.svstools.com | iex lauched the UI as intended
#>
# need to test
# Write-Host "🛠️ SAMY - Script Automation Monkey (Yeah!)" -ForegroundColor Cyan
#endregion changes to be done
@@ -427,8 +429,10 @@ $subHtml
#endregion Build-Checkboxes
### Get SVSMSP module version to display in the UI
function Get-ModuleVersionHtml {
#region Get-ModuleVersionHtml
### Get SVSMSP module version to display in the UI
function Get-ModuleVersionHtml {
$mod = Get-Module -ListAvailable -Name SVSMSP | Sort-Object Version -Descending | Select-Object -First 1
if ($mod) {
return "<div style='color:#bbb; font-size:0.9em; margin-top:1em;'>Module Version: $($mod.Version)</div>"
@@ -436,8 +440,11 @@ $subHtml
return "<div style='color:#f66;'>SVSMSP_Module not found</div>"
}
# Starts the HTTP listener loop
function Start-Server {
#endregion Get-ModuleVersionHtml
#region Strat-Server
# Starts the HTTP listener loop
function Start-Server {
# make it accessible to Dispatch-Request
$Global:Listener = [System.Net.HttpListener]::new()
$Global:Listener.Prefixes.Add("http://localhost:$Port/")
@@ -459,6 +466,7 @@ $subHtml
Write-LogHybrid "Listener closed." "Info" "Server"
}
}
#endregion Strat-Server
#region UIHtml
function Get-UIHtml {
@@ -1348,8 +1356,10 @@ $script
#endregion Handler Stubs
# Sends the HTML for a given page or invokes a task handler
function Dispatch-Request {
#region Dispatch-Request
# Sends the HTML for a given page or invokes a task handler
function Dispatch-Request {
param($Context)
# figure out the path
@@ -1389,8 +1399,9 @@ $script
$Context.Response.StatusCode = 404
Respond-Text $Context '404 - Not Found'
}
#endregion Dispatch-Request
#region EntryPoint: Define Invoke-ScriptMonkey
#region EntryPoint: Define Invoke-ScriptMonkey
# ─────────────────────────────────────────────────────────────────────────
# 3) MAIN LOGIC (Toolkit vs DattoFetch vs DattoInstall vs UI)
@@ -1474,10 +1485,7 @@ $script
}
#endregion EntryPoint: Define Invoke-ScriptMonkey
Write-Host "🛠️ SAMY - Script Automation Monkey (Yeah!)" -ForegroundColor Cyan
Write-Host "ParameterSetName: $($PSCmdlet.ParameterSetName)" -ForegroundColor Yellow
#region — guarantee NuGet provider is present without prompting
#region — guarantee NuGet provider is present without prompting
# ─── Top of script ───
Import-Module PackageManagement -Force -ErrorAction SilentlyContinue | Out-Null
@@ -1524,11 +1532,7 @@ $script
#endregion
# If we got here, it's the UI set—launch browser + listener:
# ——— UI fallback starts here ———
Write-LogHybrid "Launching UI" Info Startup
#region Install-DattoRMM-Helper
#region Install-DattoRMM-Helper
function Install-DattoRMM-Helper {
param (
[string]$ApiUrl,
@@ -1582,7 +1586,7 @@ $script
}
#endregion
#region HTTP Listener & Routing
#region HTTP Listener & Routing
# Handle shutdown command
if ($path -eq 'quit') {