moved #region ScriptMonkey run silently Entrypoint

This commit is contained in:
2025-06-29 13:46:05 -04:00
parent 790c2491d0
commit ffab89a69a

View File

@@ -1,9 +1,5 @@
# region changes to be done # region changes to be done
# if (Get-Command msedge.exe -ErrorAction SilentlyContinue) {
# Start-Process msedge.exe -ArgumentList "--app=http://localhost:$Port"
#} else {
# Start-Process "microsoft-edge:http://localhost:$Port"
#}
#endregion #endregion
<# <#
@@ -122,6 +118,71 @@
[Parameter(ParameterSetName='DattoInstall')][switch] $SaveCopy [Parameter(ParameterSetName='DattoInstall')][switch] $SaveCopy
) )
#region ScriptMonkey run silently Entrypoint
# ─────────────────────────────────────────────────────────────────────────
# 3) MAIN LOGIC (Toolkit vs DattoFetch vs DattoInstall vs UI)
# ─────────────────────────────────────────────────────────────────────────
switch ($PSCmdlet.ParameterSetName) {
'Toolkit' {
Write-LogHybrid "Toolkit-only mode" Info Startup
Install-SVSMSP -InstallToolkit
return
}
# ───────────────────────────────────────────────────────────
# 2) If user only wants the site list, do that and exit
# ───────────────────────────────────────────────────────────
'DattoFetch' {
Write-LogHybrid "Fetching site list only…" Info DattoAuth
$sites = Get-DattoRmmSites -Password $N8nPassword
$ext = [IO.Path]::GetExtension($OutputFile).ToLower()
if ($ext -eq '.json') {
$sites | ConvertTo-Json -Depth 3 | Out-File -FilePath $OutputFile -Encoding UTF8
} else {
$sites | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8
}
Write-LogHybrid "Wrote $($sites.Count) sites to $OutputFile" Success DattoAuth
return
}
# ────────────────────────────────────────────
# 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 `
-ApiSecretKey $Global:ApiSecretKey `
-SiteUID $SiteUID `
-SiteName $SiteName `
-PushSiteVars:$PushSiteVars `
-InstallRMM:$InstallRMM `
-SaveCopy:$SaveCopy
}
return
}
'UI' {
Write-LogHybrid "Launching UI" Info Startup
Write-Host "Starting ScriptMonkey UI on http://localhost:$Port/" -ForegroundColor Cyan
Start-Process "msedge.exe" -ArgumentList "--app=http://localhost:$Port"
Start-Server # blocks until you click Exit
return
}
}
#endregion ScriptMonkey run silently Entrypoint
Write-Host "ParameterSetName: $($PSCmdlet.ParameterSetName)" -ForegroundColor Yellow Write-Host "ParameterSetName: $($PSCmdlet.ParameterSetName)" -ForegroundColor Yellow
#region — guarantee NuGet provider is present without prompting #region — guarantee NuGet provider is present without prompting
@@ -1501,70 +1562,7 @@ $script
#endregion #endregion
#region ScriptMonkey run silently Entrypoint
# ─────────────────────────────────────────────────────────────────────────
# 3) MAIN LOGIC (Toolkit vs DattoFetch vs DattoInstall vs UI)
# ─────────────────────────────────────────────────────────────────────────
switch ($PSCmdlet.ParameterSetName) {
'Toolkit' {
Write-LogHybrid "Toolkit-only mode" Info Startup
Install-SVSMSP -InstallToolkit
return
}
# ───────────────────────────────────────────────────────────
# 2) If user only wants the site list, do that and exit
# ───────────────────────────────────────────────────────────
'DattoFetch' {
Write-LogHybrid "Fetching site list only…" Info DattoAuth
$sites = Get-DattoRmmSites -Password $N8nPassword
$ext = [IO.Path]::GetExtension($OutputFile).ToLower()
if ($ext -eq '.json') {
$sites | ConvertTo-Json -Depth 3 | Out-File -FilePath $OutputFile -Encoding UTF8
} else {
$sites | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8
}
Write-LogHybrid "Wrote $($sites.Count) sites to $OutputFile" Success DattoAuth
return
}
# ────────────────────────────────────────────
# 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 `
-ApiSecretKey $Global:ApiSecretKey `
-SiteUID $SiteUID `
-SiteName $SiteName `
-PushSiteVars:$PushSiteVars `
-InstallRMM:$InstallRMM `
-SaveCopy:$SaveCopy
}
return
}
'UI' {
Write-LogHybrid "Launching UI" Info Startup
Write-Host "Starting ScriptMonkey UI on http://localhost:$Port/" -ForegroundColor Cyan
Start-Process "msedge.exe" -ArgumentList "--app=http://localhost:$Port"
Start-Server # blocks until you click Exit
return
}
}
#endregion ScriptMonkey run silently Entrypoint
} }
if ($MyInvocation.InvocationName -eq '.') { if ($MyInvocation.InvocationName -eq '.') {