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