concept InlineScript in category powershell

This is an excerpt from Manning's book Windows PowerShell in Action, Third Edition.
The workflow keyword 1 defines the start of the workflow. A foreach statement 2creates a loop. The –parallel parameter ensures the loop’s iterations are run in parallel rather than sequentially. An InlineScript 3 is used to write out the current iteration details and Get-Process 4 is used to determine the number of PowerShell processes in use.
This is where InlineScript comes to the rescue. An InlineScript block can contain any and all valid PowerShell commands irrespective of their being normally supported in workflows.
In many cases InlineScript (or inline functions) are the only practical way to use workflow. Using the workflow activity to get a registry key is ludicrously slow. Workflow is best used to sequence largish blocks of code that you don’t want to repeat.
You can use an InlineScript block in the main body of the workflow, inside a loop or control statement, or nested inside a parallel or sequential block. The syntax is illustrated in figure 12.4.
An InlineScript block has the activity common parameters including –PSPersist, but the PowerShell commands inside the InlineScript block don’t gain any of the activity common parameters or workflow features such as checkpointing.
Variables defined in a workflow aren’t visible to an InlineScript block, but the $using scope modifier can be used to access those variables; see section 12.3.2.
Using an InlineScript block is illustrated here.