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 {