PowerShell Command
Verb: powerShell
Available from: <Standard>
Executes a command written in the Windows PowerShell language.
Syntax
powerShell [--handleerror(Boolean)] [--apartmentState(ApartmentState)] [--fromfile(Boolean)] --file(String) --script(String) (Boolean)=success (List<String>)=errors (List<String>)=warnings
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--handleerror | Handle Error | Optional | Boolean | When enabled, if an error occurs during the execution of the selected script, the current script does not fail and the information regarding the error that occurred is returned in the outputs. Otherwise, if there is an error, the script will fail. |
--apartmentState | "Thread" Type | Optional | ApartmentState | Forms of division of the process that must be used in the execution, being them STA or MTA. |
--fromfile | Execute from File | Optional | Boolean | If enabled, allows you to run the script with the PowerShell commands contained in a file. |
--file | File | Only whenExecute from File is True | Text | Full directory path and name of the file that has the Windows PowerShell commands that should be executed. |
--script | Powershell Script | Only whenExecute from File is False | Text | PowerShell commands, known as cmdlets, which use the Windows PowerShell language. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
success | Success | Boolean | Returns "True" if the PowerShell script runs successfully, or "False" if it doesn't. |
errors | Errors | List<Text> | Returns a list of errors resulting from running the PowerShell script. |
warnings | Warnings | List<Text> | Returns a list of warnings from running the PowerShell script. |
Example
The "get-Process" command is executed to obtain the process that is running on the local computer, returning its execution success, errors and warnings, if any.
defVar --name success --type Boolean
defVar --name errorList --type List --innertype String
defVar --name waningsList --type List --innertype String
powerShell --apartmentState "STA" --script "Get-Process" success=success errorList=errors waningsList=warnings
logMessage --message "Success: ${success}\r\nError: ${errorList}\r\nWarnings: ${waningsList}" --type "Info"
// Result: True
// Error: []
// Warnings: []
The output values vary according to the execution of the script on the Windows device.