We Use Cookies

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with this.

See our cookie policy.

Automation Action: Execute PowerShell

Execute PowerShell commands and assign the results to a variable.

Built-In Action

Executes a Windows PowerShell command or script. Returns the response to a ThinkAutomation variable.

Enter the PowerShell Command or Script or specify PowerShell Script File.

In the PowerShell Command or Script you can either specify the command and it's parameters or you can specify the command only and then provide parameter names, values & types in the Parameters Grid.

Example - Single Command With Parameters

To get the current Windows version. Set the PowerShell Command to Get-ItemProperty and add parameters:

Parameter Name Value Type
Path HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion String
Name ReleaseId String
You can use %variable% replacements for parameter values (or part of).
If you need to pass multiple values to a single parameter, you need to send through a special ThinkAutomation array type. To do this, prefix your parameter value with the word ARRAY: followed by comma-separated values.

This will return:

ReleaseId    : 2009
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT
PSChildName  : CurrentVersion
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry              

Example - Command

You can also execute a PowerShell command/script. Set the Command to:

(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId

You can use %variable% replacements inside the Command, eg:

(Get-ItemProperty -Path "%RegKey%" -Name ReleaseId).ReleaseId

Nothing should be specified in the Parameters grid.

The above will return 2009.

Remember to enclose string parameters in quotes.

Wait Max (Seconds)

Specify the maximum seconds to wait for the command or script to execute. If the command or script does not complete within the specified number of seconds then an error will be raised. This setting prevents scripts that do not properly handle timeouts from halting execution of the Automation.

Assign To

Select the variable that you want the Response to be assigned to. The entire PowerShell command response will be assigned to the field/variable.


You can use the Test button to test the Command/Script. The response will be displayed and also copied to the clipboard.

External Modules

If your PowerShell command or script uses external modules/cmdlets you need to enter the module names in the Import Module Names entry. Separate multiple modules with commas. You can use the module name or path.

In order to be able to run the PowerShell script you need to set an appropriate PowerShell Execution Policy. For guidance on this from Microsoft, see: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6