From 0d6c4da47cd1c8ebe7c415a9642be2f680c79a79 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Wed, 2 Jul 2025 21:35:40 -0400 Subject: [PATCH] updated the synopsis --- StackMonkey_Beta.ps1 | 130 ++++++++++++++++++++++++++++++++----------- 1 file changed, 98 insertions(+), 32 deletions(-) diff --git a/StackMonkey_Beta.ps1 b/StackMonkey_Beta.ps1 index 05de089..02a0ac5 100644 --- a/StackMonkey_Beta.ps1 +++ b/StackMonkey_Beta.ps1 @@ -17,55 +17,121 @@ and optional silent install of the SVSMSP toolkit and headless DattoRMM deployment. .DESCRIPTION - Provides an HTTP-hosted GUI for selecting and running tasks (module installs, tweaks, offboarding, etc.). - When invoked with the correct parameters, it can silently install the SVSMSP toolkit and perform a headless - DattoRMM deployment without ever launching the browser or UI. + Install-DattoRMM is a single, unified toolkit for Datto RMM operations. It can be used + interactively or via HTTP endpoints, and includes built-in validation and error trapping. -.PARAMETER SilentInstall - Runs only the SVSMSP module install (Install-Toolkit) and skips launching the browser/UI. + Key features: + • Credential retrieval – securely fetches ApiUrl, ApiKey, and ApiSecretKey from a webhook. + • OAuth management – automatically acquires and refreshes bearer tokens over TLS. + • Site list fetching – returns the list of RMM sites; validates OutputFile to .csv or .json. + • Site list saving – writes fetched site list to the user’s Desktop as CSV or JSON. + • Registry variable push – writes site-specific variables under HKLM:\Software\SVS\Deployment. + • Agent download & install – downloads the Datto RMM agent installer and launches it. + • Installer archiving – saves a copy of the downloaded installer to C:\Temp. + • HTTP endpoints – exposes `/getpw` and `/installDattoRMM` handlers, each wrapped in try/catch + to log errors and return proper HTTP 500 responses on failure. + • Idempotent & WhatIf support – uses ShouldProcess for safe, testable agent installs. -.PARAMETER DattoApiUrl - The Datto Automate API base URL for headless deployment. + Throughout, secrets are never written to logs or console, and all operations produce + clear success/failure messages via Write-LogHybrid. ``` -.PARAMETER DattoApiKey - Your Datto Automate API username. -.PARAMETER DattoApiSecretKey - Your Datto Automate API password/secret. +.PARAMETER UseWebhook + Switch that forces credential retrieval from the webhook at WebhookUrl using WebhookPassword. + When omitted, you must supply ApiUrl, ApiKey, and ApiSecretKey directly. -.PARAMETER SiteUID - The target Datto site UID for headless installation. +.PARAMETER WebhookPassword + Password to authenticate to the credentials-fetch webhook. Mandatory when -UseWebhook is set. -.PARAMETER SiteName - The target Datto site name for headless installation. +.PARAMETER WebhookUrl + URL of the credentials webhook endpoint. Defaults to $Global:DattoWebhookUrl. + +.PARAMETER ApiUrl + Direct Datto RMM API base URL (used if not fetching from webhook). + +.PARAMETER ApiKey + Direct Datto RMM API key (used if not fetching from webhook). + +.PARAMETER ApiSecretKey + Direct Datto RMM secret (used if not fetching from webhook). + +.PARAMETER FetchSites + Switch to fetch the list of RMM sites and skip all install or variable-push actions. + +.PARAMETER SaveSitesList + Switch to save the fetched site list to the desktop as a file named by OutputFile. + Must be used together with -FetchSites. + +.PARAMETER OutputFile + Name of the file to write the site list to (must end in “.csv” or “.json”). + Defaults to 'datto_sites.csv'. .PARAMETER PushSiteVars - Switch to include site variables in the headless DattoRMM install. + Switch to fetch site-specific variables and write them under HKLM:\Software\SVS\Deployment. .PARAMETER InstallRMM - Switch to install the RMM agent in the headless DattoRMM install. + Switch to download and launch the Datto RMM agent installer for the specified site. .PARAMETER SaveCopy - Switch to download the RMM installer executable during the headless DattoRMM install. + Switch to save a copy of the downloaded Datto RMM installer into C:\Temp. + +.PARAMETER SiteUID + The unique identifier of the Datto RMM site. Mandatory when performing install or variable-push. + +.PARAMETER SiteName + The friendly name of the Datto RMM site (used in logging). Mandatory when performing install or variable-push. .EXAMPLE - & ([ScriptBlock]::Create( - (iwr 'https://sm.svstools.com' -UseBasicParsing).Content - )) ` - -N8nPassword 'pwd' ` - -SiteUID 'site-123' ` - -SiteName 'Acme Corp' ` - -InstallRMM ` + # Fetch and save site list via webhook + Install-DattoRMM -UseWebhook -WebhookPassword 'Tndmeeisdwge!' -FetchSites -SaveSitesList -OutputFile 'sites.csv' + +.EXAMPLE + # Headless install with site variables + Install-DattoRMM -ApiUrl 'https://api.example.com' -ApiKey 'KeyHere' -ApiSecretKey 'SecretHere' \ + -SiteUID 'site-123' -SiteName 'Acme Corp' -PushSiteVars -InstallRMM + +.EXAMPLE + # Download and save installer to C:\Temp without installing + Install-DattoRMM -ApiUrl 'https://api.example.com' -ApiKey 'KeyHere' -ApiSecretKey 'SecretHere' \ + -SiteUID 'site-123' -SiteName 'Acme Corp' -SaveCopy + +.EXAMPLE + & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com' -UseBasicParsing).Content )) ` + -UseWebhook ` + -WebhookPassword 'pwd' ` + -FetchSites ` + -SaveSitesList ` + -OutputFile 'sites.json' + +.EXAMPLE + & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com' -UseBasicParsing).Content )) ` + -ApiUrl 'https://api.example.com' ` + -ApiKey 'YourApiKey' ` + -ApiSecretKey 'YourSecretKey' ` + -SiteUID 'site-123' ` + -SiteName 'Acme Corp' ` -PushSiteVars ` - -SaveCopy ` + -InstallRMM + +.EXAMPLE + & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com' -UseBasicParsing).Content )) ` + -ApiUrl 'https://api.example.com' ` + -ApiKey 'YourApiKey' ` + -ApiSecretKey 'YourSecretKey' ` + -SiteUID 'site-123' ` + -SiteName 'Acme Corp' ` + -SaveCopy + +.EXAMPLE + & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com' -UseBasicParsing).Content )) ` + -ApiUrl 'https://api.example.com' ` + -ApiKey 'YourApiKey' ` + -ApiSecretKey 'YourSecretKey' ` + -SiteUID 'site-123' ` + -SiteName 'Acme Corp' ` + -InstallRMM ` -WhatIf -.EXAMPLE - & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com/ScriptMonkey.ps1' -UseBasicParsing).Content)) -N8nPassword '' -FetchSitesOnly -OutputFile '' - -.EXAMPLE - & ([ScriptBlock]::Create( (iwr 'https://sm.svstools.com/ScriptMonkey.ps1' -UseBasicParsing).Content )) -N8nPassword 's3cr3t' -FetchSitesOnly - .EXAMPLE & ([ScriptBlock]::Create((iwr 'sm.svstools.ca').Content )) -SilentInstall