PowerShell Cmdlet Parameters and Inheritance
- by Adam Driscoll
I have an interface:
public interface X
{}
I have a class:
public class Y : X
{}
I have one cmdlet:
[Cmdlet("Get", "Y")]
public class GetYCmdlet : PSCmdlet
{
protected override void ProcessRecord()
{
WriteObject(new Y());
}
}
I have another cmdlet:
[Cmdlet("Set", "X")]
public class SetYCmdlet : PSCmdlet
{
[Parameter]
public X SomeObj {get;set;}
}
When I do this:
$y = Get-Y
Set-X -SomeObj $y
I get this:
Could not convert "Y" to "X". Method
not supported.
Any ideas?