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