Create a shorthand function for pipelines #21294
-
I'm using |
Beta Was this translation helpful? Give feedback.
Answered by
MartinGC94
Mar 9, 2024
Replies: 1 comment 5 replies
-
Yes, just define a function that takes pipeline input and also does what you want, for example:
Though it's probably worth noting that there already is a wrapper for your use case called |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are right, I didn't think that one through. It creates a new pipeline for each item. You could do it like this though:
This uses the automatic variable
$input
which contains all the input data that was passed to the function, see: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.4#input