Product: Powershell Universal
Version: 1.5.14
Running in IIS
Having issues executing scripts when they have a parameter.
I’ve made a simple script without parameters, just to make sure everything is working properly. This works as expected.
Working script contents…
‘hello world’
Called via…
$script = Get-UAScript -Name emptyScript.ps1
Invoke-UAScript -Script $script
However, when the content is changed to include a simple parameter, it throws an error.
Param([string]$test)
$test
PS 80 [4/9/2021 11:37:46 PM] C:\
$script = Get-UAScript -Name emptyScript.ps1
PS 81 [4/9/2021 11:38:06 PM] C:\
Invoke-UAScript -Script $script -test ‘hello’
Invoke-UAScript : Sequence contains no matching element
At line:1 char:1
- Invoke-UAScript -Script $script -test ‘hello’
+ CategoryInfo : NotSpecified: (:) [Invoke-UAScript], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,UniversalAutomation.InvokeScriptCommand
The log file doesn’t appear to show a problem…
2021-04-09T23:38:22.4449821-04:00 0HM7ROGMIULH2:00000003 [INF] Request starting HTTP/1.1 GET http://myServer.domain.local/api/v1/Script/emptyScript.ps1 (ca22a1cb)
2021-04-09T23:38:22.4467406-04:00 0HM7ROGMIULH2:00000003 [INF] Authorization was successful. (0d575a54)
2021-04-09T23:38:22.4467778-04:00 0HM7ROGMIULH2:00000003 [INF] Executing endpoint ‘“UniversalAutomation.ScriptController.Get (UniversalAutomation)”’ (500cc934)
2021-04-09T23:38:22.4468265-04:00 0HM7ROGMIULH2:00000003 [INF] Route matched with “{action = "Get", controller = "Script"}”. Executing controller action with signature “UniversalAutomation.Script Get(System.String)” on controller “UniversalAutomation.ScriptController” (“UniversalAutomation”). (122b2fdf)
2021-04-09T23:38:22.4475167-04:00 0HM7ROGMIULH2:00000003 [INF] Executing ObjectResult, writing value of type ‘“UniversalAutomation.Script”’. (8a1b66c8)
2021-04-09T23:38:22.4476419-04:00 0HM7ROGMIULH2:00000003 [INF] Executed action “UniversalAutomation.ScriptController.Get (UniversalAutomation)” in 0.7939ms (afa2e885)
2021-04-09T23:38:22.4476642-04:00 0HM7ROGMIULH2:00000003 [INF] Executed endpoint ‘“UniversalAutomation.ScriptController.Get (UniversalAutomation)”’ (99874f2b)
2021-04-09T23:38:22.4477019-04:00 0HM7ROGMIULH2:00000003 [INF] Request finished in 2.7402ms 200 application/json; charset=utf-8 (791a596a)
2021-04-09T23:38:27.4558560-04:00 0HM7ROGMIULH2:00000004 [INF] Request starting HTTP/1.1 GET http://myServer.domain.local/api/v1/script/4/parameter (ca22a1cb)
2021-04-09T23:38:27.4576617-04:00 0HM7ROGMIULH2:00000004 [INF] Authorization was successful. (0d575a54)
2021-04-09T23:38:27.4576980-04:00 0HM7ROGMIULH2:00000004 [INF] Executing endpoint ‘“UniversalAutomation.ScriptController.GetParametersById (UniversalAutomation)”’ (500cc934)
2021-04-09T23:38:27.4577542-04:00 0HM7ROGMIULH2:00000004 [INF] Route matched with “{action = "GetParametersById", controller = "Script"}”. Executing controller action with signature “UniversalAutomation.ScriptParameter GetParametersById(Int64)” on controller “UniversalAutomation.ScriptController” (“UniversalAutomation”). (122b2fdf)
2021-04-09T23:38:27.4584451-04:00 0HM7ROGMIULH2:00000004 [INF] Executing ObjectResult, writing value of type ‘“UniversalAutomation.ScriptParameter”’. (8a1b66c8)
2021-04-09T23:38:27.4585644-04:00 0HM7ROGMIULH2:00000004 [INF] Executed action “UniversalAutomation.ScriptController.GetParametersById (UniversalAutomation)” in 0.7814ms (afa2e885)
2021-04-09T23:38:27.4585921-04:00 0HM7ROGMIULH2:00000004 [INF] Executed endpoint ‘“UniversalAutomation.ScriptController.GetParametersById (UniversalAutomation)”’ (99874f2b)
2021-04-09T23:38:27.4586472-04:00 0HM7ROGMIULH2:00000004 [INF] Request finished in 2.8089ms 200 application/json; charset=utf-8 (791a596a)
2021-04-09T23:38:27.8399705-04:00 0HM7ROGMIULH2:00000005 [INF] Request starting HTTP/1.1 GET http://myServer.domain.local/api/v1/script/4/parameter (ca22a1cb)
2021-04-09T23:38:27.8417987-04:00 0HM7ROGMIULH2:00000005 [INF] Authorization was successful. (0d575a54)
2021-04-09T23:38:27.8418424-04:00 0HM7ROGMIULH2:00000005 [INF] Executing endpoint ‘“UniversalAutomation.ScriptController.GetParametersById (UniversalAutomation)”’ (500cc934)
2021-04-09T23:38:27.8418941-04:00 0HM7ROGMIULH2:00000005 [INF] Route matched with “{action = "GetParametersById", controller = "Script"}”. Executing controller action with signature “UniversalAutomation.ScriptParameter GetParametersById(Int64)” on controller “UniversalAutomation.ScriptController” (“UniversalAutomation”). (122b2fdf)
2021-04-09T23:38:27.8425873-04:00 0HM7ROGMIULH2:00000005 [INF] Executing ObjectResult, writing value of type ‘“UniversalAutomation.ScriptParameter”’. (8a1b66c8)
2021-04-09T23:38:27.8426868-04:00 0HM7ROGMIULH2:00000005 [INF] Executed action “UniversalAutomation.ScriptController.GetParametersById (UniversalAutomation)” in 0.7663ms (afa2e885)
2021-04-09T23:38:27.8427092-04:00 0HM7ROGMIULH2:00000005 [INF] Executed endpoint ‘“UniversalAutomation.ScriptController.GetParametersById (UniversalAutomation)”’ (99874f2b)
2021-04-09T23:38:27.8427500-04:00 0HM7ROGMIULH2:00000005 [INF] Request finished in 2.8004ms 200 application/json; charset=utf-8 (791a596a)
Greatly appreciate your help, I will