PowerShell plugin issue with param

i set “String Parameter” in “This project is parameterized” for username and password
but when i try to run below i get error

1 param ($username, $password)
2 Connect-VIServer -Server myserver -Protocol https -User $($env:username) -Password $($env:password)

e[91mparam: e[0m/tmp/jenkins8171739391719656217.ps1:2
e[96mLine |
e[96m 2 | e[0m e[96mparame[0m (
e[96m | e[91m ~~~~~
e[91me[96m | e[91mThe term ‘param’ is not recognized as a name of a cmdlet,
e[96m | e[91mfunction, script file, or executable program. Check the
e[96m | e[91mspelling of the name, or if a path was included, verify that
e[96m | e[91mthe path is correct and try again.
Build step ‘PowerShell’ marked build as failure
Finished: FAILURE

okay? I don’t powershell but it sounds like powershell doesn’t know what param is. Are you expecting this is something jenkins specifically handles?

This looks like [JENKINS-63153] Jenkins powershell-plugin 1.4 breaks code with param() - Jenkins Jira

Even if the PowerShell plugin were corrected to make Param work in scripts again, it still would not automatically translate Jenkins build parameters to PowerShell script parameters. I think PowerShell might then prompt for parameter values and hang the build.

To actually use Jenkins build parameters in a PowerShell script that you run using the PowerShell plugin, I think you should make the script read them from environment variables. Related: Pipeline Syntax page - Document that parameters become environment variables · Issue #4967 · jenkins-infra/jenkins.io · GitHub

If you were instead using a pipeline with “powershell” or “pwsh” steps, then you could alternatively use the ‘${params.NAME}’ syntax to make Jenkins substitute the parameter values into the script. This however looks less safe than environment variables, because if the parameter value itself contains a quotation mark or a backtick, then that can interfere with how PowerShell parses the script.