If you are doing advanced functions and have the parameters decorated [parameter()], would there be any reason to NOT decorate a parameter with [Parameter()] . I've seen this a few times and don't know whether its just a case of laziness, oversight, or purposeful design.
1 Answer
Laziness I think but to be fair, it isn't needed if you aren't using any special parameter attibutes like Mandatory, Position, etc. As long is one parameter is marked [Parameter(...)] or the param block is marked [CmdletBinding(...)] PowerShell will interpret that function as an advanced function. OTOH there is no harm in adding the empty [Parameter()] to parameters.
3 Comments
klumsy
Yeah i think though if you are using it on any, its probably best to be consistent, especially if you are doing some parametersets IMO.
Keith Hill
FWIW, that is what I usually do.
JasonMArcher
It is probably best to put them on all parameters... but I do tend to leave them off of switches.