You can start the wizard from the BlueParq Designer or the BlueParq Editor.
BlueParq Designer
- Press the right mouse button, the BlueParq Radial Menu will present itself.
- Press the Add cmdlet call button
Trick: CTRL-2
Press the CTRL and 2 key simultaneously to call the wizard directly
BlueParq Editor
- In the Bottom Navigation bar of the BlueParq Editor, click the Show cmdlet wizard button
Trick: CTRL-2
Press the CTRL and 2 key simultaneously to call the wizard directly
The iteration wizard
- After opening the wizard the following screen will be displayed:
Add infinite loop protection
Add infinite loop protection in case you don't want to wait a long time...
- As you can see in the above screen you have a couple options to create your iteration:
- Counter: loop a number of times and perform an action at the specified increment.
- Iterate over a collection: this can be:
- A file or the content of a file.
- A typed list.
- An XML file.
- A CSV file, with a delimiter.
- A Hashtable, with Keys and Values.
- Generate your own, with a prefix, start value, increment, end value and post fix.
- Condition: loop as long as the specified condition is or isn't fulfilled.
- Timer: loop for a specified period of time.
Comments are great for documenting your PowerShell scripts!
The comments you create on several places will automatically be added to your annotations.
Counter
- Choose the Counter radio button.
- You can add a start value, end value and increment value. In this example the iteration will loop from 0 to 10, one step at a time.
- Click Finish and the block or PowerShell code will be created.
Iterate over a collection
- Choose the Iterate over a collection radio button.
- You can choose to iterate between the following collection methods:
- A file or the content of a file.
- A typed list.
- An XML file.
- A CSV file, with a delimiter.
- A Hashtable, with Keys and Values.
- Generate your own, with a prefix, start value, increment, end value, and postfix.
- In this example we will use the List collection and will add Hello world as with each letter on a single line.
- Click Finish and the block or PowerShell code will be created.
Condition
- In order to work with the Condition option, you first have to create a variable assignment.
- The fastest way is to click on the sign of the Variables node.
- Create a Boolean, just like the example below.
- In the BlueParq Editor you can add the following line of PowerShell code: [Bool] $LoopingAllTheWay = $true
- Press Save and then open the iteration wizard.
- Choose the Condition radio button.
- Now you can add logic to your condition, for example wait until a service is stopped or a process is started.
- Click Finish and the block or PowerShell code will be created.
Wise choice
In the above example it's a very wise choice to check the Add infinite loop protection checkbox.
Timer
- Choose the Timer radio button.
- You can add the total run loop time value and a perform action interval in this screen. In this example the iteration will loop 60 seconds, and will perform an action every 10 seconds.
- Click Finish and the block or PowerShell code will be created.
Result in the BlueParq Designer
We will use our Hello world example in the Iterate over a collection option.
- If we generate the diagram we will get the following result:
- Nice! But not very spectacular. As the loop will iterate each letter in the Hello world lines, but it will do that and nothing more.
- Let's just show the output of each letter. First of all right mouse click on the Group Element, the BlueParq Radial Menu will appear.
- Press the cmdlet wizard and press Echo in the search field. Also, check out the cmdlet wizard tutorial here.
- Press Echo under Alias and press Next.
- Make sure you add $item in the InputObject text box.
- Press Finish and the cmdlet block will be added within the Group Element.
Result in the BlueParq Editor
We will use our Hello world example in the Iterate over a collection option.
- If we generate the diagram we will get the following result:
ForEach ($item In ('H','e','l','l','o','','w','o','r','l','d'))
{
}
- Nice! But not very spectacular. As the loop will iterate each letter in the Hello world lines, but it will do that and nothing more.
- Let's just show the output of each letter.
- Press the cmdlet wizard from the Bottom Navigation bar and press Echo in the search field. Also checkout the cmdlet wizard tutorial here.
- Press Echo under Alias and press Next.
- Make sure you add $item in the InputObject text box.
- Press Finish and the cmdlet block will be added within the ForEach iteration.
ForEach ($item In ('H','e','l','l','o',' ','w','o','r','l','d'))
{
Microsoft.PowerShell.Utility\Write-Output -InputObject $item
}