Invoke-PSUScript on Docker

Product: PowerShell Universal
Version: 3.0.5
Docker image from Hub

Hi there,

I’m currently having some issues invoking script from API.

I’m currently trying to do the following :

Invoke-PSUScript -Script 'script.ps1' -pvar $var -Integrated | Tee-Object -Variable job | Wait-PSUJob -Integrated

Get-PSUJobPipelineOutput -Job $job -Integrated

And this result to :

Invoke-RestMethod: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1657028909.749102440","description":"Error received from peer ipv4:127.0.0.1:36875","file":"/var/local/git/grpc/src/core/lib/surface/call.cc","file_line":1068,"grpc_message":"Exception was thrown by handler.","grpc_status":2}")

I’ve tried the same using the Computername Param and the AppToken param but I’m facing the following issue:

Invoke-RestMethod: Cannot retrieve the dynamic parameters for the cmdlet. Call failed with status code 404 (Not Found): GET https://psu.mysite.com/api/v1/script/5/parameter
at , : line 6
at , : line 1

Any Idea could cause this ?

I cant’ reproduce this one.

endpoint


New-PSUEndpoint -Url "/test" -Method @('GET') -Endpoint {
Invoke-PSUScript -Script 'P.ps1' -Nice cool -Integrated | Tee-Object -Variable job | Wait-PSUJob -Integrated

Get-PSUJobPipelineOutput -Job $job -Integrated
}

script

param($Nice)

$Nice

I didn’t configure anything else. I’m not quite sure why it would be able to load the scripts but not the parameters.

Can you try navigating to the URLs directly in a browser?

https://psu.mysite.com/api/v1/script/5
https://psu.mysite.com/api/v1/script/5/parameter

I forgot to mention that I have OIDC configured with OKTA.

The problem seems that as soon management API, in this situation, can’t authenticate using AppToken…

I can query the custom endpoints, but get a 404 on management API.

Do you have any idea what I’m doing wrong or is it something on your end ? Management API are working on web browser though.

In addition, I noticed as well that when OIDC is enabled tokens posses no Identity value nor CreatedBy.

I have SQL connection setup on that container.

Many thanks in advance for your help on this

I’m not sure why that is happenign but I’ll get that configured and see if I can reproduce. I’ll open an issue to track this.

Can you do me a favor and try running Get-PSUScript in your environment from within your API?

I want to see what is returned. From what I can tell, it doens’t make much sense that it could return the script but then fail to look up the parameters.

I’m particuarlly looking for script with the ID 5 (unless you’ve changed the scripts).

Hey Adam !

Thanks for your answer, I did the test and get-psuscript works properly:

    "ScriptParameters": [
      {
        "Id": 0,
        "Name": "ptype",
        "DisplayName": null,
        "Type": "System.String",
        "Script": null,
        "DefaultValue": null,
        "Required": true,
        "DisplayType": 0,
        "ValidValues": null,
        "HelpText": null,
        "ParameterSet": "Default"
      },
      {
        "Id": 0,
        "Name": "pname",
        "DisplayName": null,
        "Type": "System.String",
        "Script": null,
        "DefaultValue": null,
        "Required": true,
        "DisplayType": 0,
        "ValidValues": null,
        "HelpText": null,
        "ParameterSet": "Default"
      },
      {
        "Id": 0,
        "Name": "creds",
        "DisplayName": null,
        "Type": "System.Management.Automation.PSCredential",
        "Script": null,
        "DefaultValue": "$secret:mysecret",
        "Required": false,
        "DisplayType": 5,
        "ValidValues": null,
        "HelpText": "Must be domain short name",
        "ParameterSet": "Default"
      }
    ],

looks params are discovered properly, but once I do “invoke-psuscript” it fails…

is it normal that all params have a ID = 0 ?

kinda weird