Scripting - Powershell

Scripting - Powershell

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.

Use

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 Windows Management Framework 4.0.  See https://www.microsoft.com/en-us/download/details.aspx?id=40855

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 = 'https://webapi.wizbangwidgets.com/User/GetToken'
$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 = 'https://webapi.wizbangwidgets.com/ControlSetValue/UpdateControlSetValue_String'
    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

Variables - Workflow

HelpMaster Web API

Control Powershell use via application security roles

System Event Log

System Administration

Security Setting to enable/disable SQL