From 8c59f5b836b791df62cad5de5d58cbba610fe504 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Thu, 18 Dec 2025 18:48:50 -0500 Subject: [PATCH] fixed theo error --- samy.ps1 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/samy.ps1 b/samy.ps1 index 5cd3a63..fc2cf6f 100644 --- a/samy.ps1 +++ b/samy.ps1 @@ -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