From 287c8a547b9ccb073eff9d6ff8f2f881c35772b1 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Mon, 16 Feb 2026 20:59:56 -0500 Subject: [PATCH] added function Get-TaskHandlerName --- src/samy.functions.ps1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/samy.functions.ps1 b/src/samy.functions.ps1 index 28a913b..e29731b 100644 --- a/src/samy.functions.ps1 +++ b/src/samy.functions.ps1 @@ -1,3 +1,27 @@ +function Get-TaskHandlerName { + [CmdletBinding()] + param( + [Parameter(Mandatory)] + $Task + ) + + # Prefer explicit handler properties if present + foreach ($p in 'HandlerFn','Handler','Fn','Function','Script') { + if ($Task.PSObject.Properties.Name -contains $p) { + $v = [string]$Task.$p + if (-not [string]::IsNullOrWhiteSpace($v)) { return $v } + } + } + + # Fallback: task.Name (your server routes use Name) + if ($Task.PSObject.Properties.Name -contains 'Name') { + $v = [string]$Task.Name + if (-not [string]::IsNullOrWhiteSpace($v)) { return $v } + } + + return $null +} + #region Web: Remote Fetch Helpers function Get-RemoteText {