ironmansoftware / universal-automation

Universal Automation is the PowerShell-first automation platform.
https://ironmansoftware.com/universal-automation/
MIT License
24 stars 4 forks source link

Ad-Hoc Script Execution Doesn't Support Default Parameter Values #113

Closed mattmcnabb closed 4 years ago

mattmcnabb commented 4 years ago

If I write a script that includes a default parameter value and then execute the script, the value for that parameter is null. I would expect the default parameter value to be honored.

Consider this script:

param ($Query = "roundhouse")
$Response = Invoke-RestMethod -Uri "https://api.chucknorris.io/jokes/search?query=$Query"

If I run this without setting the $Query parameter in the Run wizard, I get this error:

[02/28/2020 13:50:28] [ERROR] The remote server returned an error: (500) Internal Server Error.
at <ScriptBlock>, <No file>: line 5
[02/28/2020 13:50:28] [ERROR] Cannot validate argument on parameter 'InputObject'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
at <ScriptBlock>, <No file>: line 6
[02/28/2020 13:50:28] [ERROR]

However, I can set the same value in the Run wizard and the script succeeds.

Version Information

adamdriscoll commented 4 years ago

Resolved. It will also show the default value in the UI.