Invoke Powershell Get Result

Invokes the powershell file or command specified in the Command Text expression. This activity will attempt to convert the result to the type specified at creation, by either using the Initialization Action or simply performing a cast.

note

When pasting the command directly in CommandText, we must tick Is Script property for the command to work.

Most of the properties on this activity can be set using variable expressions which must be enclosed inside double quotation marks “”.

Designer Properties#

Invoke Powershell designer
  1. Command Text The command text, or the Microsoft Windows PowerShell file to be executed. When using the command directly in the Command Text, we must tick Is Script property for the command to work.
  2. Initialization Action It may be set to (we may drop an activity) a custom activity that has an input Argument of type PSObject and returns a value of the type specified when InvokePowerShellWithResult is dropped into the workflow.

Properties#

Invoke Powershell properties

Power Shell#

  1. Command Text See Designer Properties above.
  2. Input Represents the pipeline input for the powershell script. The input is represented as an IEnumerable(object).
  3. Is Script Sets the method of how the script is executed. Checked when using a PowerShell script command directly in Command Text; Unchecked when using a powershell file in Command Text.
  4. Parameters The parameters to be sent to the power shell script. Represented as a Dictionary(string, object), where key is the name of the parameter and value is its value.
  5. Power Shell variables The predefined powershell variables.Represented as a Dictionary(string, object), where is key is the name of the variable and value is its value.

General Properties#

See General Properties.

Misc#

See Misc.

Out Error#

  1. Errors The output errors reported by the powershell script as a Collection of ErrorRecord. For more information about ErrorRecord please https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.errorrecord?view=powershellsdk-7.0.0
  2. Output Error See Out Error.
  3. String Errors All the power shell errors concatenated by new line in a string.

Output#

  1. Output The result of the execution as a Collection of specified type(the type specified when the activity was dropped on the workflow).
  2. String Result The result of the execution converted to string and separated by new Line.

Example#

Get disk count using powerShell

In this example, the ‘Invoke PowerShell Get Result’ activity will get a count of discs/disks available to the desktop, using the Microsoft PowerShell command "(get-disk | measure).Count", then display the result in a Message Box.

To get the result, we use the "result" variable and set that to "String Result" in powershell activity properties.