From 061d582242bbf65b563c3140b436d5698cc04d8e Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sun, 22 Jun 2025 16:53:39 -0400 Subject: [PATCH] Update StackMonkey.ps1 --- StackMonkey.ps1 | 72 +++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index 74f2dbd..80b3395 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -43,23 +43,53 @@ #region ScriptMonkey run silently Entrypoint - -[CmdletBinding()] +[CmdletBinding(DefaultParameterSetName='UI')] param( + # ───────────────────────────────────────────────────────── + # Toolkit-only mode + [Parameter(Mandatory,ParameterSetName='Toolkit')] [switch]$SilentInstall, - [string]$DattoApiUrl, - [string]$DattoApiKey, - [string]$DattoApiSecretKey, - [string]$SiteUID, - [string]$SiteName, - [switch]$PushSiteVars, - [switch]$InstallRMM, - [switch]$SaveCopy + + # ───────────────────────────────────────────────────────── + # Datto headless mode + [Parameter(Mandatory,ParameterSetName='Datto')] + [ValidateNotNullOrEmpty()] + [string] $DattoApiUrl, + + [Parameter(Mandatory,ParameterSetName='Datto')] + [ValidateNotNullOrEmpty()] + [string] $DattoApiKey, + + [Parameter(Mandatory,ParameterSetName='Datto')] + [ValidateNotNullOrEmpty()] + [string] $DattoApiSecretKey, + + [Parameter(Mandatory,ParameterSetName='Datto')] + [ValidateNotNullOrEmpty()] + [string] $SiteUID, + + [Parameter(Mandatory,ParameterSetName='Datto')] + [ValidateNotNullOrEmpty()] + [string] $SiteName, + + [Parameter(ParameterSetName='Datto')] + [switch] $PushSiteVars, + + [Parameter(ParameterSetName='Datto')] + [switch] $InstallRMM, + + [Parameter(ParameterSetName='Datto')] + [switch] $SaveCopy ) -# If full-UI is disabled but we got all Datto params, run install and exit -if ($DattoApiUrl -and $DattoApiKey -and $DattoApiSecretKey -and $SiteUID -and $SiteName) { - Write-LogHelper -Message "Headless DattoRMM deploy" -Level Info -TaskCategory "Startup" +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 ` @@ -70,7 +100,9 @@ if ($DattoApiUrl -and $DattoApiKey -and $DattoApiSecretKey -and $SiteUID -and $S -InstallRMM:$InstallRMM ` -SaveCopy:$SaveCopy return -} + } + +# If we got here, it's the UI set—launch browser + listener: <# oneliner to silently install DRMM & ( [ScriptBlock]::Create( (iwr 'https://sm.svstools.com/ScriptMonkey.ps1' -UseBasicParsing).Content )) ` @@ -83,18 +115,6 @@ if ($DattoApiUrl -and $DattoApiKey -and $DattoApiSecretKey -and $SiteUID -and $S -PushSiteVars #> - -# If the user asked for a silent install, do just that and quit -if ($SilentInstall) { - Write-LogHelper -Message "Silent install requested" -Level Info -TaskCategory "Startup" - Install-SVSMSP -InstallToolkit - return -} - -#endregion ScriptMonkey run silently Entrypoint - - - # STACK = Scripted Tooling for Automated Client Kickoff # MONKEY = Module-based Onboarding & Next-step Kickoff Engine Yoke # Conveys the idea of coupling tasks together and keeping them under control.