Create a PowerShell Job in Rundeck

Create PowerShell Job – This guide explains how to create a PowerShell job in Rundeck, configure the workflow, target nodes, runtime options, parallel execution, and pass option values into a PowerShell script.

Useful external reference: Rundeck documentation.

Create a New Job

  • Open the Rundeck console.
  • Create a New Job.
Create PowerShell Job screenshot
Rundeck new job page for creating an automation job

Details Tab

  • Enter the job name.
  • Add a clear description.
Rundeck job details tab with name and description fields

Workflow Tab

  • Add a step: Run Script.
  • Edit your PowerShell script.
  • Invocation example: powershell.exe -ExecutionPolicy RemoteSigned -File.
  • Script file extension: .ps1.
Rundeck workflow tab with a Run Script step
PowerShell script configuration in a Rundeck workflow step

Nodes Tab

  • Node filter: .* to match all nodes.
  • Allow users to change the filter at run time.
  • Increase the number of nodes executed in parallel if needed.
  • If a node fails, allow execution on another selected device.
Rundeck nodes tab with node filter configuration
Rundeck node execution settings for parallel runs and failure behavior

Other Tab

  • Enable Multiple Executions to allow concurrent runs.
Rundeck Multiple Executions setting for concurrent job runs

Define a Runtime Option

Create PowerShell Job – Add a new option to pass a value to your script at run time.

Useful external reference: Rundeck documentation.

  • Option Type: Text.
  • Option Name and Label: UpgradeOrGetVersion with no spaces.
  • Input Type: Plain Text.
  • Allowed Values: List, for example Upgrade;GetVersion.
  • List delimiter: ;.
  • Required: Yes.
Rundeck option type and input settings for a PowerShell job
Rundeck allowed values list for the UpgradeOrGetVersion option

Use the Option in PowerShell

Create PowerShell Job – Reference the option with @option.UpgradeOrGetVersion@ and assign it to a PowerShell variable.

Useful external reference: Rundeck documentation.

Rundeck option reference inserted into a PowerShell script
  • Example in PowerShell:
$Action = "@option.UpgradeOrGetVersion@"

switch ($Action) {
  'Upgrade'   { Write-Host 'Running upgrade...';  # your code here }
  'GetVersion'{ Write-Host 'Getting version...';  # your code here }
  default     { throw "Unknown action: $Action" }
}
Rundeck PowerShell job execution with the selected runtime option