From 20d398c57cd35d6f38d99d10646cc61b4eacc35b Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Wed, 2 Jul 2025 18:05:09 -0400 Subject: [PATCH] Update StackMonkey_Beta.ps1 --- StackMonkey_Beta.ps1 | 46 ++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/StackMonkey_Beta.ps1 b/StackMonkey_Beta.ps1 index b9cc4b6..838734b 100644 --- a/StackMonkey_Beta.ps1 +++ b/StackMonkey_Beta.ps1 @@ -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,17 +429,22 @@ $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 "
Module Version: $($mod.Version)
" } return "
SVSMSP_Module not found
" } + + #endregion Get-ModuleVersionHtml - # Starts the HTTP listener loop - function Start-Server { + #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) @@ -1473,11 +1484,8 @@ $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') {