From 03237d691c8956b141b4c6ae6c26b5610205af06 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Tue, 24 Jun 2025 19:12:40 -0400 Subject: [PATCH] Update StackMonkey.ps1 --- StackMonkey.ps1 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index 90747f2..1bf89d0 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -170,10 +170,15 @@ switch ($PSCmdlet.ParameterSetName) { if (-not $creds) { throw "Failed to retrieve Datto API credentials from n8n" } - # overwrite the parameters with what we just fetched - $DattoApiUrl = $creds.ApiUrl - $DattoApiKey = $creds.ApiKey - $DattoApiSecretKey = $creds.ApiSecretKey + + # 1) Fetch creds + $creds = Get-DattoApiCredentials -Password $N8nPassword + if (-not $creds) { throw "Could not fetch creds" } + + # 2) Store in globals for everyone else + $Global:ApiUrl = $resp.ApiUrl + $Global:ApiKey = $resp.ApiKey + $Global:ApiSecretKey = $resp.ApiSecretKey Write-LogHelper "Fetched Datto API credentials from n8n" Success DattoAuth } @@ -186,9 +191,9 @@ switch ($PSCmdlet.ParameterSetName) { # 2) Invoke the existing Install-DattoRMM cmdlet # ──────────────────────────────────────────── Install-DattoRMM ` - -ApiUrl $DattoApiUrl ` - -ApiKey $DattoApiKey ` - -ApiSecretKey $DattoApiSecretKey ` + -ApiUrl $Global:ApiUrl ` + -ApiKey $Global:ApiKey ` + -ApiSecretKey $Global:ApiSecretKey ` -SiteUID $SiteUID ` -SiteName $SiteName ` -PushSiteVars:$PushSiteVars `