ironmansoftware / universal-automation

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

Execute script from dashboard with parameters #6

Closed mattmcnabb closed 4 years ago

mattmcnabb commented 4 years ago

Please consider adding the capability to specify parameters when running a script ad-hoc. This will support the use case of publishing scripts for a team to run on demand with parameterized input.

leeberg commented 4 years ago

The dashboard should be doing some of this already but the support is pretty limited. I'll take a look and beef this up. If the SCript has defined params we should be discovering them programmatically and allowing input - but it may not be robust enough or simply failing a param check!

mattmcnabb commented 4 years ago

My script is pretty simple:

[CmdletBinding()]
param
(
    [Parameter()]
    [string]
    $Domain = (Get-UAVariable -Name "DuckDnsDomain").Value,

    [string]
    $IPAddress = (irm "https://api.ipify.org"),

    [string]
    $Token = (Get-UAVariable -Name "DuckDnsApiToken").Value,

    [string]
    $BaseUri = (Get-UAVariable -Name "DuckDnsBase").Value
)

$Uri = "{0}?domains={1}&token={2}&ip={3}" -f $BaseUri,$Domain,$Token,$IPAddress
Invoke-RestMethod -Method Get -Uri $Uri -Verbose

I just added [CmdletBinding()] and a [Parameter()] attribute to see if that might kick off the detection, but I still don't see anything when I run the script - just a confirm button:

image

leeberg commented 4 years ago

Great Example!

Even our SUPER basic "Parameters" test script is having the same problem. The script should be getting analyzed and then the parameters are supposed to be automatically read. That modal should be programmatically showing each param on run, but it is not.

param($Test1, $Test2, $Test3) $Test1; $Test2; $Test3
adamdriscoll commented 4 years ago

Fixed in tonight's build.