PowerShell Module Basics
  • 12 Jul 2021
  • 2 Minutes to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

PowerShell Module Basics

  • Dark
    Light

Article summary

Overview

The PowerShell Module allows the execution of Powershell scripts from Flows. PowerShell is a powerful scripting platform that has a large number of integration plugins to integrate with system software and enterprise applications.  

The Powershell Module is required to use Powershell scripts. To learn how to install modules, see Installing Modules in Decisions.

   

The following is not required to install Powershell Module but a workaround for Powershell Functionality
Open Powershell as Administrator and run the following command:
Enable-PSRemoting -Force 
The following response should be returned:

By default, WS-Man and Powershell remoting use ports 5985 and 5986 for connections over HTTP and HTTPS, respectively.


Below are links to example scripts and a Flow that uses these scripts: these zip files can be imported to Decisions and illustrate the different ways the PowerShell module can be used.


Example

This example will demonstrate how to configure Powershell in Decisions.

  1. In Decisions Studio, navigate to System > Integrations > Powershell Script Projects. Click ADD SCRIPT PROJECT.
  2. 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.
  3. Right-click on the new Powershell Script Project and click Add Script.
  4. 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.
    Criteria for input values:
    • Must be strings
    • Must match the PowerShell token name exactly (without the $ symbol). For example, if a user wants to set the value of the $TextFilePath variable in the script, put TextFilePath in the Inputs section of the script editor.
    • Array input can be inputted as a comma-separated list. This mimics the behavior of the Windows PowerShell Console, i.e. if a user wants to set the value of the variable in Get-Process $ProcNames a valid input value for that could be Chrome, Explorer, Skype.
    Criteria for outcome values:
    PowerShell steps cannot return structured data, however, when a script returns an object, users can specify members of that object to return as string arrays. For example, the Get-Process cmdlet returns Process objects which have properties including ProcessName and Id. These properties can be specified as outputs of the step which are then outputted as string arrays at runtime. For more information, see Process Objects.


  5. Click OK to return to Powershell Script Project. 
  6. In a Flow Designer, click the Done path on the Start step. Navigate to Integrations > All Integrations > Powershell > [Script Project Name]. Select the script step and click ADD. The values entered for the Input and Output categories should show up on the step.
    All PowerShell steps have an option to Run Remotely. Enabling this option exposes new inputs that allow the user to specify which machine to remotely run the script. This “Run Remotely” option uses “WS-Management-based Windows PowerShell remoting". 




Was this article helpful?