PowerShell
Purpose
Windows PowerShell is a shell initially developed by Microsoft for task automation and configuration management. Initially, a Windows-only component, known as Windows PowerShell, but it is now an open-source project that can be installed on Windows, macOS, and Linux platforms. PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language.
Yarado has built-in integration for PowerShell, so instead of rebuilding automation scripts in RPA you can directly include and incorporate them. Yarado's integrates with PowerShell via the System.Automation.dll, which offers the additional benefit of eliminating the need for traditional PowerShell to store scripts on disk, making it suitable to save passwords and secrets.
Double click the icon or drag it to the process visuliser to use the PowerShell function.
Using PowerShell
The PowerShell step is a step that must be created manually because it is not possible to provide the required information when you are using the recording mode.
Note
PowerShell inherits privileges from the Yarado Client, meaning that if the Yarado Client is running as administrator, so is the command line.
Yarado variables are available everywhere users can type text, including the PowerShell script text box.
Enter your PowerShell script.
Interface elements
Element | Description |
---|---|
Link variable or enter PowerShell script | In this large text box area, you are free to enter your PowerShell script, or (partially) replace its content using one or more variables. |
Ouput to variable | Optionally, you can link the output of your PowerShell script to a variable. Doing so can be useful in case you want to use PowerShell to manipulate the contents of a variable. You can also overwrite variables, meaning that you can use a variable in the script area and also use that same variable as the output variable. |
TimeOut | Set a timeout value in seconds. If the PowerShell step doesn't genereate a result within the timeout period, Yarado will proceed to the next step. |
Generate Error on Timeout | A checkbox that lets you decide whether you want have Yarado generate an error in case your PowerShell exceeds the timeout value. |
Shortcut for entering variables
You can also input variables by right-clicking in the textbox. You can choose between user or system variables, like the day or date of the system.
Example
Send a Message Card to a Microsoft Teams Connector
Note
This example assumes you are able to create a Microsoft Teams webhook. You can find more information on this topic in Microsoft's documentation here.
For this example, we will use a PowerShell script to send a message card to a Microsoft Teams channel using the Teams webhook connector. This step is particularly useful if you want to receive notifications on the performance of your Yarado task directly in Teams.
This example was as the final step of a Yarado task that automatically imported credit card statements into a company's bookkeeping.
-
Create three variables:
%teamsconnector%
where you can paste your Teams Webhook.%rows%
for the number of imported credit card statement rows. (In the original task, this variable was populated by the task itself. For this example, you can enter any value you like.)%output%
for any PowerShell output. This greatly helps debugging potential errors.
Variables used in this example.
-
Create a new PowerShell step by double clicking on PowerShell in the toolbox on the left, or by dragging it to the process visualiser.
-
Copy the following PowerShell code and paste it into the Link variable or enter PowerShell script text box.
Your PowerShell step should now look like this:$httpBody = '{ "@type": "MessageCard", "@context": "http://schema.org/extensions", "themeColor": "6FD770", "summary": "Yarado finished importing credit card statements", "sections": [ { "activityTitle": "Yarado finished importing credit card statements", "facts": [ { "name": "Imported", "value": "%rows% rows" }, { "name": "Runtime", "value": "%totalruntime%" } ], "markdown": true } ] }' $null = Invoke-WebRequest -Uri '%teams_connector%' -Method Post -Body $httpBody
PowerShell script for sending webhooks to Teams.
-
Link your
%output%
variable to the Output to variable field using the dropdown. Optionally, you can adjust the TimeOut to your preference but in general, 60 seconds is a good default. -
Click Save to close the window.
-
Click start to run run your command.
Click start.
You should get a notification in your Teams channel within seconds.
Tip
You can replace all parts of the PowerShell with a variable. For
example, $httpBody = '%variable%'
turns the entire webhook
body into a variable; this can be useful if you want to use another step to
dynamically generate your message body.