Skip to main content


PowerShell data sources

Use PowerShell data sources to populate Form elements with the output of a custom PowerShell script. They are the most commonly used type of data source, and the most powerful.

To get started, Add a PowerShell data source.


Scripts in PowerShell data sources can be executed by an On-premises Service Automation Agent or your Cloud Service Automation Agent.

Return results in PowerShell data sources

The last line of your script should return a hash table with the results, either directly or with Write-Output. For example:

$result = @{weather = "Current time: $($response.hourly.time[0]); current temperature: $($response.hourly.temperature_2m[0]) degrees $temperatureUnit (PowerShell datasource)"}
Logging in PowerShell data sources

PowerShell data sources use native PowerShell logging.

  • Write-Information "Information"

  • Write-Host "Equivalent to Write-Information"

  • Write-Error "An error"

  • Write-Warning "A warning"

  • Write-Verbose -Verbose "Verbose requires the -Verbose flag"

  • Write-Debug -Debug "Debug requires the -Debug flag"

Script log messages are displayed in the Received Logs tab during preview. To view them in production, View data source logs or View logs.

Audit logging in PowerShell data sources

When you create, edit, or delete a PowerShell data source, the action is automatically logged in the Audit logs.

Writing custom messages into audit logs from PowerShell data sources is not currently supported.