Powershell script task

A powershell script task will inject and execute the same powershell script on several windows nodes concurrently.

This kind of task allows you to maintain the scripts of all your servers through a single interface.

This only works with Windows nodes.

Here is an example:

Write-Host 'Hello!'

Using project constants

Project constants can be used in the script content as environment variables prefixed with CPC_ (for CtFreak Project Constant).

Here’s an example using a project constant named NUMBER_OF_RETENTION_DAYS:

Write-Host "Delete backup files older than $env:CPC_NUMBER_OF_RETENTION_DAYS days"
…

If you later decide to increase the retention period of your backups, you’ll only need to modify the constant value to affect all cleanup scripts referring to it.

Using task parameters

Like project constants, task parameters can be used in the script content as environment variables prefixed with CTP_ (for CtFreak Task Parameter).

Here’s an example using a text task parameter named FIRST_NAME:

Write-Host "Hello $env:CTP_FIRST_NAME !"

Task parameters values are converted to text format when assigned to an environment variable.

The following conversion rules are applied according to parameter type:

  • Checkbox → Checked: true, Unchecked: false
  • Date → Formatting with the YYYY-MM-DD pattern
  • Selector, Integer and Text → No specific formatting