Passing output from one script to the next

How do you pass the serialized object output of one script to another in PUA?

It depends a little on how you are calling one script to another. We don’t yet have pipeline support Invoke-UAScript so you’d have to pass it in as a dynamic parameter.

Script1.ps1

Get-Process

Script2.ps1

$Output = Get-UAScript 'Script1.ps1' | Get-UAJob -OrderBy Id -OrderDirection Descend | Get-UAPipelineOutput
Invoke-UAScript -Name 'Script3.ps1' -Output $Output

Script3.ps1

param($Output)

$Output

We’re working out the details of chaining scripts together to create pipelines and triggers but don’t have that sorted quite yet.

Awesome, thanks Adam.

Hey gang! Is this thread still current? I was just searching about piping scripts together 'coz this would be something we’d want from PSU (we haven’t installed/bought it yet).

I’d love to be able to create a script “Get-Stuff.ps1” and another “Set-Stuff.ps1” and then have a scheduled job that pipes the “get” to the “set”, but also a dashboard that just calls the “get”. Keep things modular. Is it as simple as “Get-Stuff.ps1 | Set-Stuff.ps1” or is the trick above still necessary?

The above trick is still required. I think I failed to open an issue for this so it was never implemented.

1 Like

Hi Adam! I did see that you opened an issue for this on GH and closed it a while back. Did it ship with the latest release? I haven’t tried PSU yet but I was keeping an eye on this one as it’s definitely a use case that’s near and dear to me!

We’ve improved this a bit. The Invoke-UAScript now provides a -wait parameter that eliminates the need to call additional cmdlets to get the pipeline output.

$Output = Invoke-UAScript Script1.ps1 -Wait
Invoke-UAScript Script2.ps1 -Output $Output