Update samy.ps1

This commit is contained in:
2026-01-12 12:50:24 -05:00
parent 7870c1efd3
commit b55ee3ff26

View File

@@ -2019,11 +2019,9 @@ function Install-DattoRMM {
#region EntryPoint: Define Invoke-ScriptAutomationMonkey
# ─────────────────────────────────────────────────────────────────────────
# 3) MAIN LOGIC (Toolkit vs DattoFetch vs DattoInstall vs UI)
# ─────────────────────────────────────────────────────────────────────────
switch ($PSCmdlet.ParameterSetName) {
'Toolkit' {
Write-LogHybrid "Toolkit-only mode" Info Startup -LogToEvent
Install-SVSMSP -InstallToolkit
@@ -2036,10 +2034,6 @@ function Install-DattoRMM {
return
}
# ───────────────────────────────────────────────────────────
# 2) If user only wants the site list, do that and exit
# ───────────────────────────────────────────────────────────
'DattoFetch' {
Write-LogHybrid "Fetching site list only…" Info DattoAuth -LogToEvent
$sites = Install-DattoRMM `
@@ -2053,11 +2047,6 @@ function Install-DattoRMM {
return
}
# ────────────────────────────────────────────
# 3) Invoke the existing Install-DattoRMM cmdlet
# ────────────────────────────────────────────
'DattoInstall' {
Write-LogHybrid "Headless DattoRMM deploy" Info DattoAuth -LogToEvent
@@ -2073,13 +2062,11 @@ function Install-DattoRMM {
}
return
}
'Offboard' {
Write-LogHybrid "Headless offboarding requested" Info OffBoard -LogToEvent
# Ne garde que les tâches réellement exécutables
$offboardTasks = $Global:SamyTasks | Where-Object {
$_.Page -eq 'offboard' -and -not [string]::IsNullOrWhiteSpace([string]$_.Name)
}
@@ -2124,17 +2111,10 @@ function Install-DattoRMM {
return
}
Write-LogHybrid "Headless offboarding completed" Success OffBoard -LogToEvent
return
}
'UI' {
$url = "http://localhost:$Port/"
Write-LogHybrid "Starting ScriptAutomationMonkey UI on $url" Info Startup
# Resolve Edge path explicitly (x86 first, then 64-bit, then PATH)
$edgeCandidates = @(
"${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe",
"$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe"
@@ -2145,7 +2125,6 @@ function Install-DattoRMM {
if ($cmd) { $edgePath = $cmd.Path }
}
# Launch Edge (app mode) in a background job so Start-Server can block
Start-Job -Name 'OpenScriptAutomationMonkeyUI' -ScriptBlock {
param([string]$u, [string]$edge)
Start-Sleep -Milliseconds 400
@@ -2153,19 +2132,21 @@ function Install-DattoRMM {
if ($edge -and (Test-Path $edge)) {
Start-Process -FilePath $edge -ArgumentList @('--new-window', "--app=$u")
} else {
Start-Process -FilePath $u # fallback to default browser
Start-Process -FilePath $u
}
} catch { }
} -ArgumentList $url, $edgePath | Out-Null
# Now start the blocking listener loop
Start-Server
return
}
default {
Write-LogHybrid "Unknown ParameterSetName '$($PSCmdlet.ParameterSetName)'" Error Startup -LogToEvent
throw "Unknown mode."
}
}
#endregion EntryPoint: Define Invoke-ScriptAutomationMonkey