Update StackMonkey.ps1

This commit is contained in:
2025-06-22 23:59:34 -04:00
parent 54cf3a1f19
commit cff7f6e4a5

View File

@@ -62,6 +62,14 @@
#>
# Listening port for HTTP UI
$Port = 8082
# Configurable endpoints
$Global:DattoWebhookUrl = 'https://automate.svstools.ca/webhook/svsmspkit'
function Invoke-ScriptMonkey {
#region ScriptMonkey run silently Entrypoint
[CmdletBinding(DefaultParameterSetName='UI')]
@@ -72,6 +80,10 @@ function Invoke-ScriptMonkey {
[switch]$SilentInstall,
# ─────────────────────────────────────────────────────────
[Parameter(Mandatory,ParameterSetName='Datto')]
[string] $N8nPassword,
<# replaced by n8n
# Datto headless mode
[Parameter(Mandatory,ParameterSetName='Datto')]
#[ValidateNotNullOrEmpty()]
@@ -84,6 +96,7 @@ function Invoke-ScriptMonkey {
[Parameter(Mandatory,ParameterSetName='Datto')]
#[ValidateNotNullOrEmpty()]
[string] $DattoApiSecretKey,
#>
[Parameter(Mandatory,ParameterSetName='Datto')]
#[ValidateNotNullOrEmpty()]
@@ -110,11 +123,19 @@ function Invoke-ScriptMonkey {
return
}
'Datto' {
Write-LogHelper "Headless DattoRMM deploy" Info Startup
Write-LogHelper "Headless DattoRMM deploy (via n8n)" Info Startup
# 1) fetch creds from n8n
$creds = Get-DattoApiCredentials -Password $N8nPassword
if (-not $creds) {
throw "Failed to retrieve Datto API credentials from n8n"
}
# 2) pass them straight into the helper
Install-DattoRMM-Helper `
-ApiUrl $DattoApiUrl `
-ApiKey $DattoApiKey `
-ApiSecretKey $DattoApiSecretKey `
-ApiUrl $creds.ApiUrl `
-ApiKey $creds.ApiKey `
-ApiSecretKey $creds.ApiSecretKey `
-SiteUID $SiteUID `
-SiteName $SiteName `
-PushSiteVars:$PushSiteVars `
@@ -140,11 +161,6 @@ function Invoke-ScriptMonkey {
#region Config & Task Definitions
# Listening port for HTTP UI
$Port = 8082
# Configurable endpoints
$Global:DattoWebhookUrl = 'https://automate.svstools.ca/webhook/svsmspkit'
# Define every task once here:
@@ -279,10 +295,9 @@ function Respond-JSON {
#region Get-DattoApiCreds
function Get-DattoApiCredentials {
param ([string]$Password)
$url = "https://automate.svstools.ca/webhook/svsmspkit"
$headers = @{ "SVSMSPKit" = $Password }
try {
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method GET
$response = Invoke-RestMethod -Uri $Global:DattoWebhookUrl -Headers $headers -Method GET
return @{
ApiUrl = $response.ApiUrl
ApiKey = $response.ApiKey