Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

multiple parameters with pipeline input?

$
0
0

Hello,

The answer to this may just be that this is not a case for using pipeline input.. 

I have a function that takes two parameters, one is an object (the result of a third party web services call) and the second parameter is a string. To simply explain what the function does you can think of the object parameter like a table definition and the string parameter like the name of one of the fields... you supply the table and a fieldname and the function returns the 'ID' of that fieldname... I have this written as a normal function right now but I'm wondering if it's possible to change it to accept pipeline input... the other function I've designed as 'advanced functions' that take pipeline input typically only have one parameter.

how would I do this with my case? two params, one an object and one a simple type (string)?

1. I know I *could* make it take one object input param, and bundle that web service returned object and the other string value into a custom object and do property name binding... however that feels to me like forcing something that should not be.. I think I would put that in the 'not a case for pipeline input' bucket... but I'm unsure.

2. how could I pass these two parameters pipeline style, without doing the one custom input object approach?

I can see it for one set of them, like:
$objectParam, $stringParam | MyFunction

but how would I specify multiple sets of those two params?
$objectParam1, $stringParam1, $objectParam2, $stringParam2 | MyFunction

each iteration within the PROCESS block would work on a pair of params at a time...

maybe I'm just thinking about this all wrong... which is why I'm posting.. maybe this just is not where I should be doing pipeline input?

any input would be appreciated, thanks



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>