In my script I'm joining-by-comma a lot and would like to create a helper function that I can pipe so I could do
$fileNames | %{ "../$_.js" } | Join-ByComma
rather than having to do
($fileNames | %{ "../$_.js" }) -join ', '
I'm having trouble figuring out how to do this in a way that works with pipeline input. I've tried something like this
function Join-ByComma($arr) {
$arr -join ', '
}
and
function Join-ByComma($arr) {
Process { $_ }
End { $arr -join ', ' }
}
and neither works
You can use $Input
auto-variable, that represent pipeline input:
function Join-ByComma {
@($Input) -join ', '
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With