added list

This commit is contained in:
2025-06-29 02:40:16 -04:00
parent 2235816a64
commit bfdf53f937

View File

@@ -84,6 +84,8 @@
# ─────────────────────────────────────────────────────────
# Datto headless mode
[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,
@@ -286,8 +288,37 @@ try{
throw
}
# ───────────────────────────────────────────────────────────
# 2) If user only wants the site list, do that and exit
# ───────────────────────────────────────────────────────────
if ($FetchSitesOnly) {
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
}
# 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
}
Write-LogHybrid "Wrote $($siteList.Count) sites to $OutputFile" Success DattoAuth
return
}
# ────────────────────────────────────────────
# 2) Invoke the existing Install-DattoRMM cmdlet
# 3) Invoke the existing Install-DattoRMM cmdlet
# ────────────────────────────────────────────
if ($PSCmdlet.ShouldProcess("Datto site '$SiteName'", "Headless install")) {