Following a comment to another question, I tried adding CmdletBinding to a function. Here is a toy example
function example {
[CmdletBinding()]Param()
$args
}
But trying to use it I get:
> example foo
example : A positional parameter cannot be found that accepts argument 'foo'.
At line:1 char:1
+ example foo
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [example], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,example
What should I fix so that the function will work with any argument(s) passed to it?