Just make sure that Param should be in the first line of your PowerShell script.

If it is not in the first line, then your might get above error.

Solution Reference: https://stackoverflow.com/questions/1315140/powershell-2-0-param-keyword-error