From 30387a96891e7453b487a55b9b59f5b32e9b8e0b Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Wed, 14 Jan 2026 02:07:19 -0500 Subject: [PATCH] Add src/helpers.ps1 --- src/helpers.ps1 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/helpers.ps1 diff --git a/src/helpers.ps1 b/src/helpers.ps1 new file mode 100644 index 0000000..941214e --- /dev/null +++ b/src/helpers.ps1 @@ -0,0 +1,28 @@ +function Test-ComputerName { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string]$Name + ) + + if ([string]::IsNullOrWhiteSpace($Name)) { return $false } + if ($Name.Length -gt 15) { return $false } + if ($Name -notmatch '^[A-Za-z0-9-]+$') { return $false } + return $true +} + +function Get-TaskHandlerName { + param([object]$Task) + + foreach ($p in @('HandlerFn','Handler','Fn')) { + if ($Task.PSObject.Properties.Name -contains $p) { + $v = ([string]$Task.$p).Trim().TrimStart('/') + if (-not [string]::IsNullOrWhiteSpace($v)) { return $v } + } + } + + $n = ([string]$Task.Name).Trim().TrimStart('/') + if (-not [string]::IsNullOrWhiteSpace($n)) { return "Invoke-$n" } + + return $null +}