From fabfeb947f40ade1a6227caf64df30e57fc89ac5 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sun, 22 Jun 2025 23:40:22 -0400 Subject: [PATCH] Update StackMonkey.ps1 --- StackMonkey.ps1 | 130 ++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 60 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index f13d8bf..b5f15e6 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -39,83 +39,93 @@ .PARAMETER SaveCopy Switch to download the RMM installer executable during the headless DattoRMM install. + +.EXAMPLE + # One-liner to silently install DattoRMM via ScriptMonkey: + & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com/ScriptMonkey.ps1' -UseBasicParsing).Content )) ` + -DattoApiUrl 'https://your-datto-api-url' ` + -DattoApiKey 'yourKeyHere' ` + -DattoApiSecretKey 'yourSecretHere' ` + -SiteUID 'site-uid-value' ` + -SiteName 'My Client Site' ` + -InstallRMM ` + -PushSiteVars + +.EXAMPLE + & ([ScriptBlock]::Create( (iwr 'sm.svstools.ca').Content )) -SilentInstall + #> +function Invoke-ScriptMonkey { + #region ScriptMonkey run silently Entrypoint + [CmdletBinding(DefaultParameterSetName='UI')] + param( + # ───────────────────────────────────────────────────────── + # Toolkit-only mode + [Parameter(Mandatory,ParameterSetName='Toolkit')] + [switch]$SilentInstall, -#region ScriptMonkey run silently Entrypoint -[CmdletBinding(DefaultParameterSetName='UI')] -param( - # ───────────────────────────────────────────────────────── - # Toolkit-only mode - [Parameter(Mandatory,ParameterSetName='Toolkit')] - [switch]$SilentInstall, + # ───────────────────────────────────────────────────────── + # Datto headless mode + [Parameter(Mandatory,ParameterSetName='Datto')] + #[ValidateNotNullOrEmpty()] + [string] $DattoApiUrl, - # ───────────────────────────────────────────────────────── - # Datto headless mode - [Parameter(Mandatory,ParameterSetName='Datto')] - #[ValidateNotNullOrEmpty()] - [string] $DattoApiUrl, + [Parameter(Mandatory,ParameterSetName='Datto')] + #[ValidateNotNullOrEmpty()] + [string] $DattoApiKey, - [Parameter(Mandatory,ParameterSetName='Datto')] - #[ValidateNotNullOrEmpty()] - [string] $DattoApiKey, + [Parameter(Mandatory,ParameterSetName='Datto')] + #[ValidateNotNullOrEmpty()] + [string] $DattoApiSecretKey, - [Parameter(Mandatory,ParameterSetName='Datto')] - #[ValidateNotNullOrEmpty()] - [string] $DattoApiSecretKey, + [Parameter(Mandatory,ParameterSetName='Datto')] + #[ValidateNotNullOrEmpty()] + [string] $SiteUID, - [Parameter(Mandatory,ParameterSetName='Datto')] - #[ValidateNotNullOrEmpty()] - [string] $SiteUID, + [Parameter(Mandatory,ParameterSetName='Datto')] + #[ValidateNotNullOrEmpty()] + [string] $SiteName, - [Parameter(Mandatory,ParameterSetName='Datto')] - #[ValidateNotNullOrEmpty()] - [string] $SiteName, + [Parameter(ParameterSetName='Datto')] + [switch] $PushSiteVars, - [Parameter(ParameterSetName='Datto')] - [switch] $PushSiteVars, + [Parameter(ParameterSetName='Datto')] + [switch] $InstallRMM, - [Parameter(ParameterSetName='Datto')] - [switch] $InstallRMM, + [Parameter(ParameterSetName='Datto')] + [switch] $SaveCopy + ) - [Parameter(ParameterSetName='Datto')] - [switch] $SaveCopy -) - -switch ($PSCmdlet.ParameterSetName) { - 'Toolkit' { - Write-LogHelper "Toolkit-only mode" Info Startup - Install-SVSMSP -InstallToolkit - return - } - 'Datto' { - Write-LogHelper "Headless DattoRMM deploy" Info Startup - Install-DattoRMM-Helper ` - -ApiUrl $DattoApiUrl ` - -ApiKey $DattoApiKey ` - -ApiSecretKey $DattoApiSecretKey ` - -SiteUID $SiteUID ` - -SiteName $SiteName ` - -PushSiteVars:$PushSiteVars ` - -InstallRMM:$InstallRMM ` - -SaveCopy:$SaveCopy - return + switch ($PSCmdlet.ParameterSetName) { + 'Toolkit' { + Write-LogHelper "Toolkit-only mode" Info Startup + Install-SVSMSP -InstallToolkit + return + } + 'Datto' { + Write-LogHelper "Headless DattoRMM deploy" Info Startup + Install-DattoRMM-Helper ` + -ApiUrl $DattoApiUrl ` + -ApiKey $DattoApiKey ` + -ApiSecretKey $DattoApiSecretKey ` + -SiteUID $SiteUID ` + -SiteName $SiteName ` + -PushSiteVars:$PushSiteVars ` + -InstallRMM:$InstallRMM ` + -SaveCopy:$SaveCopy + return + } } } + + # If we got here, it's the UI set—launch browser + listener: + # ——— UI fallback starts here ——— + Write-LogHelper "Launching UI" Info Startup -<# oneliner to silently install DRMM -& ( [ScriptBlock]::Create( (iwr 'https://sm.svstools.com/ScriptMonkey.ps1' -UseBasicParsing).Content )) ` - -DattoApiUrl 'https://your-datto-api-url' ` - -DattoApiKey 'yourKeyHere' ` - -DattoApiSecretKey 'yourSecretHere' ` - -SiteUID 'site-uid-value' ` - -SiteName 'My Client Site' ` - -InstallRMM ` - -PushSiteVars -#> # STACK = Scripted Tooling for Automated Client Kickoff # MONKEY = Module-based Onboarding & Next-step Kickoff Engine Yoke