Invoke-PSUScript not starting job

Product: PowerShell Universal
Version: 2.5.4

Recently updated from 2.3.0 to 2.5.4. The dashboard button executes the onclick event (the Show-UDToast is displaying correctly), but the Invoke-PSUScript does not begin executing the script (no jobs are listed in the admin console). Previously was using the code in the following post and it was working successfully: Invoke-UAScript with -Credential - #6 by mtndrew11

Current code is as follows:

New-UDButton -Text "Apply Update" -OnClick {
Show-UDToast -Message "Updating master image..."

 $Script = Get-PSUScript -Name 'Update-baseline.ps1'
Invoke-PSUScript -Script $Script -Credential (Get-PSUVariable -Name $User)


It appears that Get-PSUVariable -Name $User is not pulling the credentials in at all during “runtime” (clicking the button). I can run this manually and it grabs the secret variable with the credentials but not from the dashboard button.

I’m not sure this isn’t working and sounds like a bug, but you can try connecting the cmdlets manually.

Try putting this at the top.

Connect-PSUServer -AppToken $PSUAppToken -Computer $PSUComputerName

Bingo! Once I added that to the top of the dashboard ps1 file, everything started working as expected again. Thanks @adam !

In general, is it best practice to have that line at the top of my dashboard ps1 files?

It should be automatically doing that but for the time being I would recommend including the Connect. We are changing the way the cmdlets do it internally so they do not require an app token or computer name. The new integrated mode uses the internal gRPC channel rather than using the REST API to call the server.

This is an example of how to do that.

Invoke-PSUScript -Name 'MyScript.ps1' -Integrated

That said, not all cmdlets support that parameter yet. In your example Get-PSUVariable won’t work in integrated mode so it’s still be to use AppTokens if you need to more than just start scripts and retrieve job information.

ok, cool! Thanks for the info and guidance as always!