Script - Powershell

Execute Powershell script via this object

The Powershell Script workflow object is used to execute a Powershell script.

workflow script

Workflow powershell script

Silent workflow object This workflow object runs silently, meaning it has no user interaction. Silent workflow object are displayed with this icon.


Write a powershell script in the workflow object (or call another script from this PS script).

Variables can also be used in the script. To insert a pre-defined variable, start typing double angular brackets "<<", and all of the available variables will be displayed in a pick-list. Choose the variable you want to inert its place-holder. It's value will be substituted for the place-holder when the script is run.

Use the Add Tag button to insert placeholder tags/tokens for the client, site, asset or job. These tags will be replaced with the unique database IDs of each entity type. These tags/tokens allow you to be specific in updates, or other SQL/Scripting actions.

workflow script edit

Powershell scripting requires that the Windows Management Framework 4.0 is installed on the machine that is running the script. See

Using workflow date variables in Powershell scripts

When using workflow date variables in a Powershell script, they are implemented as native Powershell dates. This means you can use Powershell date commands within the script against the date.

For example, the following script uses the Powershell “.AddHours” function to the date.

$Datetest = <<DateVariable>>
$Datetest = $Datetest.AddHours(3)
Write $Datetest

If you need to need to use the date within a string, you can use the following syntax to concatenate a string with the date variable.

$myJSON = "This is the first part " + (<<DateVariable>>) + " and some more text"


$myJSON = "This is the first part $(<<DateVariable>>) and some more text"

Use the .ToString function to format a date into a specific format. This may be required for API calls, or general formatting within a string.

$myJSON = "This is the first part $(<<DateVariable>>.ToString('yyyy/MM/ddTHH:mm:00')) and some more text"

See the Powershell documentation for more examples.

Example calling the HelpMaster WebAPI to update a control set

This example uses PowerShell to make a http call to the HelpMaster web api to call the UpdateControlSetValue_String method.

# Get a user token
$uri = ''
$body = '{ "apiKey": "59867a71-a601-43cd-9fc2-2eed9d164480", "loggedInUserPKID": 88 }'
$Result = Invoke-RestMethod -Uri $uri -Method Post -Body $body -ContentType "application/json"

# Store the token in a variable
$AccessToken = $result.token

# Set the parameters for the web API call
$params = @{
  Uri = ''
  Headers = @{Authorization = "Bearer $AccessToken"}
  Method = 'POST'
  Body = '{
    "entityLink": <<JobNumber>>,
    "entityType": "Job",
    "controlSetLink": 39,
    "controlGUID": "9fb6a9d5-7eae-499e-8448-46b735fba675",
    "controlValue": "This is a string value has been updated via HelpMaster workflow via a Powershell script calling the web API!"
  ContentType = 'application/json'

# Call the web API
Invoke-RestMethod @params

See Also

Execute SQL as part of workflow

Workflow Objects

Workflow Variables

HelpMaster Web API

Control Powershell use via Application Security Roles

System Event Log

System Administration

Security Setting to enable/disable SQL

PowerShell Documentation