PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,328 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I can run this script fine:
param (
[switch]$push = $false
)
Why does running this script:
param (
[switch]$push = $false
[string]$string
)
yield this error:
Missing ')' in function parameter list.
?
The error message "Missing ')' in function parameter list" is caused by the fact that the second parameter in the script is missing a comma to separate it from the first parameter. In PowerShell, parameters in a function or script must be separated by commas. To fix the error, add a comma after the first parameter like this:
param (
[switch]$push = $false,
[string]$string
)
This will allow the script to run without error and accept two parameters, a switch parameter named "push" with a default value of $false, and a string parameter named "string".
References: