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.
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 “”.
- 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.
- 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.
- Command Text See Designer Properties above.
- Input Represents the pipeline input for the powershell script. The input is represented as an IEnumerable(object).
- 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.
- 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.
- 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.
See General Properties.
- 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
- Output Error See Out Error.
- String Errors All the power shell errors concatenated by new line in a string.
- Output The result of the execution as a Collection of specified type(the type specified when the activity was dropped on the workflow).
- String Result The result of the execution converted to string and separated by new Line.
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.