fixed theo error

This commit is contained in:
2025-12-18 18:48:50 -05:00
parent ce48979759
commit 8c59f5b836

View File

@@ -2248,11 +2248,26 @@ function Install-DattoRMM {
}
# ---- Task invocation ----
$task = $Global:SamyTasks | Where-Object Name -EQ $path
if ($task) {
& $task.HandlerFn $Context
return
}
$task = $Global:SamyTasks | Where-Object Name -EQ $path $task = $Global:SamyTasks | Where-Object Name -EQ $path
if ($task) { if ($task) {
& $task.HandlerFn $Context
return $fn = $task.HandlerFn
} $cmd = Get-Command $fn -ErrorAction SilentlyContinue
if (-not $cmd) {
$Context.Response.StatusCode = 500
Send-Text $Context "Handler not found: $fn"
return
}
# If the handler declares a Context parameter, pass it by name.
# Otherwise, call it with no args (prevents HttpListenerContext getting bound to -Mode).
if ($cmd.Parameters.ContainsKey('Context')) {
& $fn -Context $Context
}
else {
& $fn
}
return
}
# ---- 404 ----
$Context.Response.StatusCode = 404