Just make sure that Param should be in the first line of your PowerShell script.
Param
If it is not in the first line, then your might get the above error.