我正在用C#开发PowerShell cmdlet,其中包含真/假的开关语句。我注意到如果我想要布尔值为true,我需要指定-SwitchName $true,否则会出现以下错误:
开关被装饰成这样:
Missing an argument for parameter 'SwitchName'. Specify a parameter of type 'System.Boolean' and try again.
开关被装饰成这样:
[Parameter(Mandatory = false, Position = 1,
, ValueFromPipelineByPropertyName = true)]
如何检测开关的存在(-SwitchName设置为true,没有-SwitchName表示false)?