views:

19

answers:

1

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?

+2  A: 

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.

x0n