- 17 May 2022
- 2 Minutes to read
PowerShell Module Basics
- Updated on 17 May 2022
- 2 Minutes to read
Any new Powershell steps should set their Run Remotely setting to True to prevent this error.
|Installation Location||Core module|
|Step Location||Integration > Powershell|
The PowerShell Module allows the execution of Powershell scripts from Flows. An instance cannot run Powershell scripts without installing this module.
PowerShell supports numerous plugins for integrating with system software and enterprise applications.
Run Powershell Remotely
Powershell can only run via remote connection.
All PowerShell steps have an option to Run Remotely. Enabling this exposes new inputs to specify which machine to remotely run the script and uses “WS-Management-based Windows PowerShell remoting".
When using the Run Remote option, users must add the IP of the VM to the TrustedHosts list during configuration by entering the following command:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value (IP Address)
To verify that the command works, use the following Powershell command:
This will allow Powershell to be ran remotely as described in this article: Computer Trusted Hosts.
Troubleshooting - Enabling Powershell Remoting
While not required for the Powershell module or for enabling remote connection, Administrators experiencing difficulties with the above option may instead enable Powershell Remoting.
This method enables remote Powershell connections on the server by calling the server itself remotely.
By default, WS-Man and Powershell remoting use ports 5985 and 5986 for connections over HTTP and HTTPS, respectively.
To enable remoting, open Powershell as an Administrator and run the following command.
The following response should be returned:
- In Decisions Studio, navigate to System > Integrations > Powershell Script Projects. Right-click Powershell Script Projects and click Add Script Project.
- On the Add Script Project window, enter a name for the Script Project that will be used and click SAVE. This name will be used as a category in the Flow Designer to group Powershell steps.
- Right-click on the new Powershell Script Project and click Add Script.
- On the Add Script window, enter a name for the script under ScriptName and the code under Script. If applicable, add input and output values.
Input values must be strings, must match the Powershell token name minus the dollar $ symbol, and must allow array input via a comma-separated list to mimic Powershell Console behavior.
Output values cannot return structured data; however, a script returning an object can specify its data members to return as string arrays. For further information, refer to the "Process Class" article in Microsoft's documentation.
- Click SAVE to return to Powershell Script Project.
- In a Flow Designer, navigate to Integration > Powershell > [Script Project Name]. Add the script step to the workspace. The values entered for the Input and Output categories should show up on the step.