Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 20 Next »

Activities

  • PS Script

PS Script

This activity runs a powershell script.

Activity Parameters

The PS Script activity parameters can be provided by manual inserted values or via IN arguments or variables:

Parameters:

  • Input Object (text box editor type) (type: string): the input object that will be shown or bind this parameter with an Output parameter of a desired activity.

As mentioned above, the values for all the required parameters can be provided by IN arguments or variables. Below is an example of predefined arguments, ready to be used by the PS Script activity:

The Read Only Output variable are the possible output values that the activity will provide:

  • DateTime Object (type: string): outputs the input object as a string.
 

 

 

 

Parameters

 
NameDescriptionType
scriptCodeEnter the Powershell script code that you want to be executed. For example: mkdir "C:\\FoundMediaSoftware " (this command creates a folder with the specified path)System.String
FilePathEnter a Powershell script file. This parameter takes precedence over the 'Script code' parameter.System.String

Read-Only Output

 
NameDescriptionType
OutputOutputs a collection of 'PSObject' type objectsSystem.Collections.ObjectModel.Collection`1 [System.Management.Automation.PSObject]
OutputRowsOutputs the number of 'PSObject' type objects returned by the execution of the scriptSystem.Int32

 

 

 

Activities

PSscript

This activity allows the user runs a powershell script.

Activity Parameters

PSscript

Input Values

This activity has two parameters. The parameter "Script file" takes precedence over the parameter "Script code". This means that whenever both parameters are filled, the "Script file" parameter will be executed and "Script code" parameter will be ignored. For showcase purposes,only "Script code" parameter will be used as input.


 


 The "ScriptCode" IN arguments is defined with default value in the Parameters section,Arguments tab in Task Designer panel. 

Output Values

The output values are stored in two defined variables. Given the case, OUT arguments may be used in the same manner. If the output values are not to be passed outside the task, variables need not be defined, but instead set the "Track Outputs" property for this activity to "Yes" and the output values will be displayed in the Tracking Data without storing them in variables/OUT arguments.

When defining the variables, the default variable type is string. The "Output " parameter is of type collection<PSObject> . To define a variable of a different type than the default ones, select the "Browse for Types.." option from the "Variable Type" column.

"Browse and Select a .Net Type" window opens. In the Search field, type "Collection" and hit "Enter". After the results are displayed, select the one of type collection<T>. Because the "Output" parameter is of type collection<PSObject>, and 'PSObject' type is not a generic one, select from the drop down list "Browse for Types.." option.  When the second "Browse and Select a .Net Type" window opens, type in the Search field, 'PSObject'. After the results are displayed, select the basic 'PSObject' option and hit "Enter". The second "Browse and Select a .Net Type" window should close. Hit "Enter" again to close the first "Browse and Select a .Net Type" window.

The "Browse and Select a .Net Type" window will close and the "Collection" defined variable will be of type Collection<Object>.

The "Count" variable should be of type "Int32" because the output parameter "Output Rows" parameter returns a value of type "Int32".

In order to display the values stored in the "Collection" variable, an iterator-type activity must be used to iterate through the elements of the collection and output the stored values. For showcase purposes, in this task, Custom ForEach activity is used to iterate through the elements of the collection and Write Line activity will be used to display the elements of the collection in the Tracking Data panel.

The "Count" variable value may be displayed in the Tracking Data panel using a Write Line activity or any other activity that displays values in the Tracking Data panel after it has been converted to string ('Count.ToString()').

 

On Execution (Home->(Execution section) Start button) -  task "Powershell_Demo"  , Tracking Data panel should display:

In order to import "Powershell_Demo" task in Flowster Studio Administrator, use Powershell_Demo.zip attachment. ( For further information check Importing Tasks in Flowster Studio Administrator )

 

 

 

  • No labels