For the complete documentation index, see llms.txt. This page is also available as Markdown.

Workflows

This feature requires a license.

PowerShell Universal workflows chain scripts and AI prompts into a single automation flow. Use workflows to pass data between steps, route execution based on a result, run independent work concurrently, and schedule the resulting process. Workflow runs create jobs that you can monitor in the standard job history.

Create a workflow

  1. Go to Build > Workflows and select Create Workflow.

  2. Enter a name and optional description.

  3. Add workflow parameters when callers must supply values such as an environment, approval target, or retention period.

  4. Save the workflow, then open it to use the Workflow Designer.

Parameters have a name, default value, required setting, and help text. They are prompted for when the workflow is run manually and are available to workflow expressions.

Build the workflow

The designer has an activity palette, a sequence canvas, and a properties pane.

  1. Add an activity by dragging it from the palette to a canvas drop zone, or select the plus button beside the activity to append it to the sequence.

  2. Select an activity to configure its properties in the right-hand pane.

  3. Drag activities in the sequence to reorder them.

  4. Select Save Workflow after making changes.

Script activities expose the PowerShell parameters defined on their target script. Provide a literal value or select PowerShell for an expression that is evaluated at runtime. AI prompt activities let you select an AI agent and provide the prompt to run.

Decision branches

Use a Decision activity to create a True and False branch. This is useful for approval flows, validation checks, and handling a prior job result.

  1. Add Decision from the activity palette.

  2. Enter a PowerShell condition that returns $true or $false. If you leave it empty, the decision evaluates the first output item from the previous activity.

  3. Use Add activity in each True or False lane to define the work for that outcome.

  4. Add any subsequent activities after the Decision; each completed branch continues to the next activity in the main workflow.

For example, a script can return whether a deployment is approved. The Decision can use the default previous-output condition, or use an explicit expression such as:

$PreviousActivity contains the prior activity's ID, type, name, job ID, status, start and end times, and pipeline output. Use it when the branch condition needs job metadata as well as its output.

Run activities in parallel

Use a Parallel activity when independent script or AI prompt activities can run at the same time.

  1. Add Parallel from the activity palette.

  2. Select Add activity in the Parallel activity and add each child activity that can run independently.

  3. Configure each child activity as usual.

  4. Continue the main workflow after the Parallel activity completes.

PowerShell Universal starts the eligible child jobs concurrently and waits for them all to finish. If an AI prompt fails, or a script child is configured to fail on script error and finishes in a failed, error, or timed-out state, the Parallel activity fails.

Pass data between activities

Workflow expressions are evaluated at runtime and can use these variables:

Variable
Use

$Workflow

Workflow parameter values supplied when the run starts.

$PSUItem

The raw pipeline output from the previous activity. A target script receives it automatically only when it declares a PSUItem parameter.

$Output

Named values produced by a previous script that returned one hashtable.

$PreviousActivity

Metadata and output for the immediately preceding activity.

For example, pass a workflow parameter to a script activity property:

To deconstruct output, have a script return exactly one hashtable:

With Deconstruct Hashtable Output enabled (the default), downstream PowerShell expressions can use the named values:

If the script returns multiple objects, or the single object is not a hashtable, use $PSUItem to work with the previous activity output instead.

Run and schedule workflows

Select the Play icon in Build > Workflows to run a workflow on demand. PowerShell Universal prompts for any configured parameters, then opens the resulting workflow job.

Create a workflow schedule from the workflow's Schedules tab or from Run > Schedules. Workflows support simple, cron, continuous, and one-time schedules. Set the same run options available for scheduled automation, including execution environment, credential, and computer settings.

Use Invoke-PSUWorkflow to start a workflow from PowerShell or other PowerShell Universal automation. You can provide parameter values when invoking it.

Manage workflows as configuration

When workflows are maintained in a configuration repository, use the configuration file explorer's Refresh Configuration > Workflows action to synchronize updated workflow definitions without restarting PowerShell Universal.

The Universal module also provides Get-PSUWorkflow, New-PSUWorkflow, Set-PSUWorkflow, Remove-PSUWorkflow, New-PSUWorkflowParameter, New-PSUWorkflowActivity, and Invoke-PSUWorkflow for configuration and automation scenarios.

Monitor and troubleshoot runs

Open the workflow job from Build > Workflows to review its status, streams, pipeline output, and errors. Child script and AI jobs are associated with the workflow run, which makes it easier to identify the activity that failed.

When troubleshooting, verify that script parameter names match the target script metadata, use an expression rather than a literal for values that must be evaluated at runtime, and remember that the first activity has no previous output.

Last updated

Was this helpful?