Is it possible to handle switch parameters with Add-Member methods?
When adding a method to a PSObject using Add-Member is it possible to use [swi开发者_开发知识库tch] parameters?
If so how does the syntax work when calling these methods?
Only commands (functions, cmdlets) can have switches that work in the way you'd expect. If you assign a scriptblock as a method, any parameters that are declared as [switch]
will be treated as if they are [bool]
, accepting only $true
or $false
.
精彩评论