When adding a method to a PSObject using Add-Member is it possible to use [switch] parameters?
If so how does the syntax work when calling these methods?
When adding a method to a PSObject using Add-Member is it possible to use [switch] 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
.