Many of our users have asked questions like:
Is there a way for me to modify the underlying powershell code after creating a worklflow?
Can I save a workflow out as a PS1 file?
Can I see the PowerShell equivalent of a workflow
There are a several ways to answer these questions, but it really boils down to explaining PowerWF workflows and what types of output PowerWF can generate for you.
All about Activities
Although PowerWF lets you easily create workflows using PowerShell cmdlets, its primary output is not a traditional PS1 file. At first this may seem odd until you realize that although every PowerShell cmdlet is a PowerWF activity, not every PowerWF activity is a PowerShell cmdlet. The Venn diagram illustrates this and shows some of the many sources of PowerWF activities.

Even if a user limits themselves to using only PowerShell activities, there is still a very good chance that they will want to take advantage of workflow features that don’t easily translate back to a simple PS1 file.
But What If I REALLY want to use it in PowerShell
Even though we don’t generate PS1 files by default, that doesn’t mean you can’t use your workflows directly from PowerShell. Any PowerWF workflow, even those that use non-PowerShell activities and features can be used directly from PowerShell scripts (PS1 files) or from the PowerShell host.
To make your workflows available as PowerShell CMDLETs, use the Deploy tab on the ribbon bar to create a PowerShell CMDLET, Snap-In, or Module.

Once a workflow has been deployed to PowerShell you can use it from the host or a PS1 file like any other CMDLET on your system.
But I Want To See and Edit the Actual PowerShell
PowerWF is bundled with PowerSE, a full featured PowerShell script editor. PowerSE lets you view the PowerShell equivalent for a workflow or part of a workflow. Every activity that is based on PowerShell will have a blue PowerShell icon in the lower left corner.
If you double-click on a PowerShell activity, a PowerShell pipeline, or a PowerShell script block, you can both view and edit the PowerShell using PowerSE.
If you multi-select a group of PowerShell activities, you can choose the Edit PowerShell option from the PowerShell icon drop-down menu.

The PowerShell commands can even be executed directly in PowerSE. PowerSE also gives you the option to save the PowerShell script out as a PS1 file.
SO…
In cases where your entire workflow is PowerShell, you can:
- Use the “Edit - Select All” option to choose all the workflow acivities.
- Choose “Edit PowerShell” from the PowerSE drop-down menu discussed above.
- Verify the script works correctly in PowerSE by pressing Play
- Save the script as a PS1 file.
1 year ago - link