question

RudolfMeier-2283 avatar image
0 Votes"
RudolfMeier-2283 asked IanXue-MSFT commented

power shell parameter binding

hi

I'm writing a Cmdlet (in C++/CLI or C#, whatever...) and, my Cmdlet has 1 parameter (it's an Int32 named a) and I did set the "ValueFromPipeline" to true... now...
I try to pass a value like this

12 | Get-MyFunction

and

it always tells me, that it cannot bind the parameter... so... does someone have a sample showing this? or can someone tell me what could be wrong?

The trace shows this

ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Get-MyFunction]
ParameterBinding Information: 0 : PIPELINE object TYPE = [System.Int32]
ParameterBinding Information: 0 : RESTORING pipeline parameter's original values
ParameterBinding Information: 0 : Parameter [a] PIPELINE INPUT ValueFromPipeline NO COERCION

... and... well... no idea where to search. Thanks for help.

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RudolfMeier-2283 avatar image
0 Votes"
RudolfMeier-2283 answered IanXue-MSFT commented

:-) ... cool... the properties do only bind correctly when you have defined a setter AND a getter... without getter, the automatic binding by type (not by name) doesn't work...

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your sharing. Please click "Accept Answer" to help other community members find it easier.

0 Votes 0 ·