Created
January 20, 2022 06:25
-
-
Save pkutaj/0cbed81a4f8a6a55bfa6f5f4968d5d3f to your computer and use it in GitHub Desktop.
Exemplary Function Accepting Multiple Inputs from Pipeline in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### func1 | |
function query-consul () { | |
param ( | |
[String[]]$consul_keys, | |
[String]$queryString, | |
) | |
foreach ($consul_key in $consul_keys) { | |
consul kv get -recurse $consul_key_ | | |
Select-String $queryString | |
if ($consul_key.length > 1) { Pause } | |
} | |
} | |
# func2 | |
function print-matches-only { | |
param([Parameter(Mandatory = $true, ValueFromPipeline = $true)][String[]]$matches) | |
begin{} | |
process{ | |
Foreach($match in $matches){return $_.Matches.Value} | |
} | |
end{} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment