Tutorial: Deploying Workflows to PowerShell
The previous tutorials have focused on creating workflows in PowerWF that leverage PowerShell, but haven’t talked about how to use those workflows in PowerShell. This tutorial will discuss how to create a PowerShell CMDLET and Modules from a PowerWF workflow.
Topics Discussed
- Deploying workflows as Cmdlets
- Deploying workflows as PowerShell Modules
Procedure
- Open the speakToMe workflow created in the previous tutorial.
- On the Deploy tab, click the “Cmdlet” button.

- PowerWF will automatically set the Name, Vendor, and Output directory, but these can be changed if desired.
- Standard PowerShell commands consist of a verb, then a noun. PowerWF includes the standard list of verbs. From the Communication group, double-click the verb “Send” to select it.

- The command now appears as “Send-speakToMe”. Change the noun to “Words” to change the command to “Send-Words”.

- Ensure that the “Launch PowerShell after build” is checked and then click the Build button.

- PowerWF will launch a PowerShell console so the cmdlet can be tested. Type “send-words” to say the default phrase, or use get-help to see the syntax for a custom phrase.

Custom phrase sample:
send-words -inputWords “wow! it works in powershell.”
- Creating a PowerShell module is almost as simple as creating a cmdlet. On the Deploy tab, click the “Module” button.

- Set the Module Name to “Speech”, then select the speakToMe Workflow and click the edit button.

- As with the cmdlet, set the verb to “Send” and the noun to “Words”. Do not check the box to make the workflow a private member of the module, or it will not be directly accessible to PowerShell.

- Click the Build button and PowerWF will launch a PowerShell console with the Speech module installed. As with the cmdlet example, test the module by typing:
send-words -inputWords “wow! it works in powershell.”
Usage Notes
- The true value of deploying modules can be seen when multiple workflows are combined in a single module. The Module Deploy automatically includes all open workflows in the module.
- If workflows are named with a standard PowerShell verb, PowerWF will automatically parse the verb-noun syntax.
- The Modules and Cmdlets built with PowerWF currently support x86 PowerShell, not 64 bit PowerShell.
- Use “install-module Speech” to install the module in other PowerShell consoles.
Summary
This tutorial showed how to deploy workflows as PowerShell cmdlets and modules. Setting the verb and noun for the cmdlets using standard PowerShell verbs was discussed. PowerWF contains the complete list of standard PowerShell verbs available for selection. If the workflow name begins with a standard PowerShell verb, PowerWF will automatically parse the verb-noun syntax for the module creation.

2 years ago - link

