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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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$trueor$false.