I want to pass parameter of custom type to my cmdlet. I declare parameter like this:
[Parameter(Position = 1)]
public StoreIdParameter Identity { get; set; }
But when I run cmdlet with parameter (like this: Get-Store VS) I get an exception:
Cannot bind parameter 'Identity'. Cannot convert the "VS" value of type "System.String" to type "R.Management.StoreIdParameter".
I created a constructor of StoreIdParameter, which accepts String but it didn't help. Should it be some type convertor from string to my type?开发者_JS百科
I have found a solution. That was my mistake - I had constructor accepting string argument only in base class. I have added constructor to derived class (StoreIdParameter) with string argument and Powershell could create an instance of this class by calling proper constructor
精彩评论