Update StackMonkey.ps1
This commit is contained in:
@@ -99,14 +99,25 @@
|
||||
[Parameter(Mandatory,ParameterSetName='Toolkit')][switch]$SilentInstall,
|
||||
# ─────────────────────────────────────────────────────────
|
||||
# Datto headless mode
|
||||
|
||||
# Both Datto sets share the webhook password
|
||||
[Parameter(Mandatory,ParameterSetName='DattoFetch'),
|
||||
Parameter(Mandatory,ParameterSetName='DattoInstall')][string]$N8nPassword,
|
||||
|
||||
# ─────────────────────────────────────────────────────────
|
||||
# Fetch‐only set: write sites and exit
|
||||
[Parameter(ParameterSetName='DattoFetch')][switch] $FetchSitesOnly,
|
||||
[Parameter(ParameterSetName='DattoFetch')][string] $OutputFile = 'datto_sites.csv',
|
||||
|
||||
[Parameter(Mandatory,ParameterSetName='Datto')][string] $N8nPassword,
|
||||
[Parameter(ParameterSetName='Datto')][switch] $FetchSitesOnly,
|
||||
[Parameter(ParameterSetName='Datto')][string] $OutputFile = 'datto_sites.csv',
|
||||
[Parameter(Mandatory,ParameterSetName='Datto')][string] $SiteUID,
|
||||
[Parameter(Mandatory,ParameterSetName='Datto')][string] $SiteName,
|
||||
[Parameter(ParameterSetName='Datto')][switch] $PushSiteVars,
|
||||
[Parameter(ParameterSetName='Datto')][switch] $InstallRMM,
|
||||
[Parameter(ParameterSetName='Datto')][switch] $SaveCopy
|
||||
|
||||
# ─────────────────────────────────────────────────────────
|
||||
# Install set: target site must be provided
|
||||
[Parameter(Mandatory,ParameterSetName='DattoInstall')][string] $SiteUID,
|
||||
[Parameter(Mandatory,ParameterSetName='DattoInstall')][string] $SiteName,
|
||||
[Parameter(ParameterSetName='DattoInstall')][switch] $PushSiteVars,
|
||||
[Parameter(ParameterSetName='DattoInstall')][switch] $InstallRMM,
|
||||
[Parameter(ParameterSetName='DattoInstall')][switch] $SaveCopy
|
||||
)
|
||||
|
||||
#region — guarantee NuGet provider is present without prompting
|
||||
@@ -308,26 +319,18 @@ try{
|
||||
# 2) If user only wants the site list, do that and exit
|
||||
# ───────────────────────────────────────────────────────────
|
||||
|
||||
if ($FetchSitesOnly) {
|
||||
'DattoFetch' {
|
||||
Write-LogHybrid "Fetching site list only…" Info DattoAuth
|
||||
try {
|
||||
$siteList = Get-DattoRmmSites -Password $N8nPassword
|
||||
}
|
||||
catch {
|
||||
Write-LogHybrid "Failed to fetch sites: $($_.Exception.Message)" Error DattoAuth
|
||||
throw
|
||||
}
|
||||
$sites = Get-DattoRmmSites -Password $N8nPassword
|
||||
|
||||
# Export based on extension
|
||||
$ext = [IO.Path]::GetExtension($OutputFile).ToLower()
|
||||
if ($ext -eq '.json') {
|
||||
$siteList | ConvertTo-Json -Depth 3 | Out-File -FilePath $OutputFile -Encoding UTF8
|
||||
}
|
||||
else {
|
||||
$siteList | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8
|
||||
$sites | ConvertTo-Json -Depth 3 | Out-File -FilePath $OutputFile -Encoding UTF8
|
||||
} else {
|
||||
$sites | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8
|
||||
}
|
||||
|
||||
Write-LogHybrid "Wrote $($siteList.Count) sites to $OutputFile" Success DattoAuth
|
||||
Write-LogHybrid "Wrote $($sites.Count) sites to $OutputFile" Success DattoAuth
|
||||
return
|
||||
}
|
||||
|
||||
@@ -337,8 +340,9 @@ try{
|
||||
# 3) Invoke the existing Install-DattoRMM cmdlet
|
||||
# ────────────────────────────────────────────
|
||||
|
||||
'DattoInstall' {
|
||||
Write-LogHybrid "Headless DattoRMM deploy" Info DattoAuth
|
||||
if ($PSCmdlet.ShouldProcess("Datto site '$SiteName'", "Headless install")) {
|
||||
|
||||
Install-DattoRMM `
|
||||
-ApiUrl $Global:ApiUrl `
|
||||
-ApiKey $Global:ApiKey `
|
||||
@@ -351,6 +355,7 @@ try{
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
}
|
||||
#endregion ScriptMonkey run silently Entrypoint
|
||||
|
||||
Reference in New Issue
Block a user