power shell parameter binding

Rudolf Meier 271 Reputation points
2021-03-31T14:27:21.3+00:00

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
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,362 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rudolf Meier 271 Reputation points
    2021-03-31T15:56:19.273+00:00

    :-) ... 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...


0 additional answers

Sort by: Most helpful