我的 cmdlet 试图从管道中获取值,但是在运行时,我收到错误消息:
无法处理管道输入,因为无法检索参数“合法性”的默认值。获得“合法性”的异常:表达式必须可读参数名称:表达式
我不知道是什么产生了这个错误..
谢谢你的帮助!代码如下..
[Cmdlet(VerbsCommon.Get, "Deals")]
public partial class GetDealCmdlet : InsightBaseCmdlet
{
private List<Object> _legalentities = new List<Object>();
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
public List<Object> Legalentity { set { _legalentities = value; } }
protected override void ProcessRecord() {...}
}
和用法:
Search-Deals xxx | Get-Deals
搜索交易是:
...
protected override void ProcessRecord()
{
foreach (PSObject in List<PSObject>)
{
....
writeObject(PSObject);
}
}