Sorry for the confusion… [switch] does caste a given parameter in to Boolean value. If you wanted to establish a default value for any parameter then =() will do so.
in this case ...
param( [switch]$test1, [switch]$test2, [switch]$test3)
Is more then sufficient since [switch] is false by default.
You have more than likely seen the following.
param ($value=$(throw '$value is required!'))
In that case, if $value is null then the default value is invoked. The default value being a throw statement. You can use this technique for almost anything, IE...
param ($dc=(([ADSI]"LDAP://rootDSE").dnshostname) #tGgggggrrrrreat script BSonPOSH
In this case if an [ADSI] object is supplied via the -$dc parameter then that object is used. If none is provided then the posh code in () is applied establishing a default parameter.
~Glenn
|