New Job

  • On the Rundeck console
  • Create a New Job

Details tab

  • Enter the job name
  • Add a clear description

Workflow tab

  • Add a step: Run Script
  • Edit your PowerShell script
  • Invocation example: powershell.exe -ExecutionPolicy RemoteSigned -File
  • Script file extension: .ps1

Nodes tab

  • Node filter: .* (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

Other tab

  • Enable Multiple Executions (allows concurrent runs)

Define an option (Workflow tab)

Add a new option to pass a value to your script at run time.

  • Option Type: Text
  • Option Name & Label: UpgradeOrGetVersion (no spaces)
  • Input Type: Plain Text
  • Allowed Values: List — enter all allowed values (e.g. Upgrade;GetVersion)
  • List delimiter: ;
  • Required: Yes

Use the option in your script

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

  • 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" }
}

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.