You could do 1 of 2 things.
Mark the parameter as mandatory, then powershell will automatically query the user for it:
PARAM( [Parameter(Mandatory=$true)][string]$sql )
PROCESS
{
"You entered: " + $sql
}
which gives:
# C:\Temp> .\prompt.ps1
cmdlet prompt.ps1 at command pipeline position 1
Supply values for the following parameters:
sql: asdsaa
You entered: asdsaa
or you could provide an expression as a default parameter that queries the input from the user:
PARAM( [string]$sql = (read-host "Enter a value for sql parameter") )
PROCESS
{
"You entered: " + $sql
}
which gives:
# C:\Temp> .\prompt.ps1
Enter a value for sql parameter: hello
You entered: hello
Edit:
In response to your comment. The only workarounds I can think of to get the behaviour you want are to either not specify the parameters and process the $args argument yourself. Or you could employ a hack that pushes the job to parsing the arguments to a separate function and then trap any errors that may occur when calling that function. So, your script would look like this:
function parsePrompt ( [string]$sql)
{
$sql
}
$cmd = "parsePrompt $($args -join " ")"
try
{
$sql = invoke-expression $cmd
}
catch [System.Management.Automation.ParameterBindingException]
{
$sql = read-host "Enter a value for sql parameter"
}
"You entered: " + $sql
which gives:
# C:\Temp> .\Prompt.ps1 -s
Enter a value for sql parameter: dsfds
You entered: dsfds
# C:\Temp> .\Prompt.ps1 -s dfds
You entered: dfds