Update StackMonkey.ps1
This commit is contained in:
@@ -63,7 +63,13 @@
|
||||
#>
|
||||
|
||||
#region ScriptMonkey run silently Entrypoint
|
||||
[CmdletBinding(DefaultParameterSetName='UI',
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
# 1) ENTRYPOINT + PARAMETER DECLARATION
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
[CmdletBinding(
|
||||
DefaultParameterSetName='UI',
|
||||
SupportsShouldProcess=$true,
|
||||
ConfirmImpact= 'Medium'
|
||||
)]
|
||||
@@ -81,6 +87,10 @@
|
||||
[Parameter(ParameterSetName='Datto')][switch] $SaveCopy
|
||||
)
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
# 2) GLOBAL SETTINGS & HELPERS
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
# Listening port for HTTP UI
|
||||
$Port = 8082
|
||||
|
||||
@@ -91,8 +101,7 @@ $Global:DattoWebhookUrl = 'https://automate.svstools.ca/webhook/svsmspkit'
|
||||
function Get-DattoApiCredentials {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Password
|
||||
[Parameter(Mandatory)][string]$Password
|
||||
)
|
||||
$headers = @{ "SVSMSPKit" = $Password }
|
||||
try {
|
||||
@@ -110,9 +119,9 @@ function Get-DattoApiCredentials {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
# 3) MAIN LOGIC (Toolkit vs Datto vs UI)
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'Toolkit' {
|
||||
@@ -126,17 +135,16 @@ function Get-DattoApiCredentials {
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# 1) Fetch URL, Key & Secret from n8n webhook
|
||||
# (this is your lines 415-424)
|
||||
# ────────────────────────────────────────────
|
||||
|
||||
# 1) Fetch creds
|
||||
$resp = Get-DattoApiCredentials -Password $N8nPassword
|
||||
if (-not $resp) { throw "Could not 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
|
||||
$Global:ApiUrl = $creds.ApiUrl
|
||||
$Global:ApiKey = $creds.ApiKey
|
||||
$Global:ApiSecretKey = $creds.ApiSecretKey
|
||||
|
||||
Write-LogHelper "Fetched Datto API credentials from n8n" Success DattoAuth
|
||||
}
|
||||
@@ -149,7 +157,7 @@ function Get-DattoApiCredentials {
|
||||
# 2) Invoke the existing Install-DattoRMM cmdlet
|
||||
# ────────────────────────────────────────────
|
||||
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("Datto site '$SiteName'", "Headless install")) {
|
||||
|
||||
Install-DattoRMM `
|
||||
-ApiUrl $Global:ApiUrl `
|
||||
@@ -160,14 +168,12 @@ function Get-DattoApiCredentials {
|
||||
-PushSiteVars:$PushSiteVars `
|
||||
-InstallRMM:$InstallRMM `
|
||||
-SaveCopy:$SaveCopy
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
#endregion ScriptMonkey run silently Entrypoint
|
||||
|
||||
|
||||
# STACK = Scripted Tooling for Automated Client Kickoff
|
||||
|
||||
Reference in New Issue
Block a user