How To Accept Multiple Values From Pipeline Into A Powershell Function

1. steps

  1. In func1, explicitly expects a list of strings as an input type [String[]]
  2. In func2, explicitly declare the parameter as an array of strings [String[]], not just a string with ValueFromPipeline = $true.
  3. In func2, you will need to use the begin{}, process{}, end{} — even though some of those blocks are just declared/empty
  4. IN func2, it does not work if you replace $match with $_ to make it more readable
▶ query-consul org.acme_prod,com.acme_dev,net.acme_qa ami_size.* | print-matches-only

ami_size:large
ami_size:large
ami_size:large

2. links

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Pavol Kutaj

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com