scripts/NullFormat.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function NullFormat { [CmdletBinding()] param ( [Parameter(Position = 0, Mandatory = $false, ValueFromPipeline = $true)] [object]$value = $null, [Parameter(Position = 1, Mandatory = $false)] [string]$format = '$_' ) process { if ($null -eq $value) { return $null } $value | ForEach-Object {"$($format -replace '\$_', $value)"} } } |