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