Update StackMonkey.ps1

This commit is contained in:
2025-06-29 04:12:59 -04:00
parent 685794945e
commit 95aded0383

View File

@@ -346,69 +346,6 @@ function Write-LogHybrid {
#endregion
# ─────────────────────────────────────────────────────────────────────────
# 3) MAIN LOGIC (Toolkit vs DattoFetch vs DattoInstall vs UI)
# ─────────────────────────────────────────────────────────────────────────
switch ($PSCmdlet.ParameterSetName) {
'Toolkit' {
Write-LogHybrid "Toolkit-only mode" Info Startup
Install-SVSMSP -InstallToolkit
return
}
# ───────────────────────────────────────────────────────────
# 2) If user only wants the site list, do that and exit
# ───────────────────────────────────────────────────────────
'DattoFetch' {
Write-LogHybrid "Fetching site list only…" Info DattoAuth
$sites = Get-DattoRmmSites -Password $N8nPassword
$ext = [IO.Path]::GetExtension($OutputFile).ToLower()
if ($ext -eq '.json') {
$sites | ConvertTo-Json -Depth 3 | Out-File -FilePath $OutputFile -Encoding UTF8
} else {
$sites | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8
}
Write-LogHybrid "Wrote $($sites.Count) sites to $OutputFile" Success DattoAuth
return
}
# ────────────────────────────────────────────
# 3) Invoke the existing Install-DattoRMM cmdlet
# ────────────────────────────────────────────
'DattoInstall' {
Write-LogHybrid "Headless DattoRMM deploy" Info DattoAuth
if ($PSCmdlet.ShouldProcess("Datto site '$SiteName'", "Headless install")) {
Install-DattoRMM `
-ApiUrl $Global:ApiUrl `
-ApiKey $Global:ApiKey `
-ApiSecretKey $Global:ApiSecretKey `
-SiteUID $SiteUID `
-SiteName $SiteName `
-PushSiteVars:$PushSiteVars `
-InstallRMM:$InstallRMM `
-SaveCopy:$SaveCopy
}
return
}
'UI' {
Write-LogHybrid "Launching UI" Info Startup
Write-Host "Starting ScriptMonkey UI on http://localhost:$Port/" -ForegroundColor Cyan
Start-Process "msedge.exe" -ArgumentList "--app=http://localhost:$Port"
Start-Server # blocks until you click Exit
return
}
}
#endregion ScriptMonkey run silently Entrypoint
# STACK = Scripted Tooling for Automated Client Kickoff
# MONKEY = Module-based Onboarding & Next-step Kickoff Engine Yoke
@@ -1559,6 +1496,68 @@ function Start-Server {
#endregion
# At the end of ScriptMonkey.ps1
Invoke-ScriptMonkey @PSBoundParameters
#region ScriptMonkey run silently Entrypoint
# ─────────────────────────────────────────────────────────────────────────
# 3) MAIN LOGIC (Toolkit vs DattoFetch vs DattoInstall vs UI)
# ─────────────────────────────────────────────────────────────────────────
switch ($PSCmdlet.ParameterSetName) {
'Toolkit' {
Write-LogHybrid "Toolkit-only mode" Info Startup
Install-SVSMSP -InstallToolkit
return
}
# ───────────────────────────────────────────────────────────
# 2) If user only wants the site list, do that and exit
# ───────────────────────────────────────────────────────────
'DattoFetch' {
Write-LogHybrid "Fetching site list only…" Info DattoAuth
$sites = Get-DattoRmmSites -Password $N8nPassword
$ext = [IO.Path]::GetExtension($OutputFile).ToLower()
if ($ext -eq '.json') {
$sites | ConvertTo-Json -Depth 3 | Out-File -FilePath $OutputFile -Encoding UTF8
} else {
$sites | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8
}
Write-LogHybrid "Wrote $($sites.Count) sites to $OutputFile" Success DattoAuth
return
}
# ────────────────────────────────────────────
# 3) Invoke the existing Install-DattoRMM cmdlet
# ────────────────────────────────────────────
'DattoInstall' {
Write-LogHybrid "Headless DattoRMM deploy" Info DattoAuth
if ($PSCmdlet.ShouldProcess("Datto site '$SiteName'", "Headless install")) {
Install-DattoRMM `
-ApiUrl $Global:ApiUrl `
-ApiKey $Global:ApiKey `
-ApiSecretKey $Global:ApiSecretKey `
-SiteUID $SiteUID `
-SiteName $SiteName `
-PushSiteVars:$PushSiteVars `
-InstallRMM:$InstallRMM `
-SaveCopy:$SaveCopy
}
return
}
'UI' {
Write-LogHybrid "Launching UI" Info Startup
Write-Host "Starting ScriptMonkey UI on http://localhost:$Port/" -ForegroundColor Cyan
Start-Process "msedge.exe" -ArgumentList "--app=http://localhost:$Port"
Start-Server # blocks until you click Exit
return
}
}
#endregion ScriptMonkey run silently Entrypoint