Invoke-PSUScript - Missing JobID?

Product: PowerShell Universal
Version: 4.3.0

We have a App / Dashboard with a button, that is using Invoke-PSUScript - nothing fancy there.

The users that are clicking the button are consuming the same script, but with different parameters.

My issue is that i would like to present the output of the script to the user, but we sometimes have several users clicking the same button at the same time - so when use the documented example, it sometimes pulls the output from another user - Jobs | PowerShell Universal

$Job = Get-PSUScript -Name 'Script.ps1' | Get-PSUJob -OrderDirection Descending -First 1
Get-PSUJobPipelineOutput -Job $Job
Get-PSUJobOutput -Job $Job

I had hoped that the Job Id would be stored in my variable, but that does not seem to be the case - example:

$Job = Invoke-PSUScript -Script "test.ps1" -Wait
Get-PSUJob -Id $job.id | Get-PSUJobOutput 

So - how can i start the script and at the same time, get the Job ID that were assigned to it, so that i can use it later on?

1 Like

Maybe I’m missing something but, why can’t you just add | Get-PSUJobOutput to the end of your Invoke-PSUSCript line?

For example, $Job = Invoke-PSUScript -Script "test.ps1" -Wait | Get-PSUJobOutput