1 / 14

Windows PowerShell

Windows PowerShell. Introducing Workflows. Trevor Sullivan | Solution Architect | Project Leadership Associates. Workflow Requirements. PowerShell version 3.0 or later PowerShell Remoting enabled TCP 5985 and TCP 5986 (SSL) Microsoft.PowerShell.Workflow PSSession Configuration.

davina
Download Presentation

Windows PowerShell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows PowerShell Introducing Workflows Trevor Sullivan | Solution Architect | Project Leadership Associates

  2. Workflow Requirements • PowerShell version 3.0 or later • PowerShell Remoting enabled • TCP 5985 and TCP 5986 (SSL) • Microsoft.PowerShell.WorkflowPSSession Configuration

  3. When to use Workflows We can take user input …. Hey, don’t forget about functions! Writing a process that is: • Long-running • Repeatable • Frequent • Parallelizable • Interruptible • Stoppable • Restart-able

  4. Creating Workflows workflow Do-Something { param ( [int] $Interval , [int] $Param2 ) Run-Activity; } Do-Something

  5. Activities vs. Cmdlets • Workflows are made up of Activities, not Cmdlets • Most core cmdlets converted to Activities • Some cmdlets explicitly excluded • Use InlineScript { … } to run non-Activity code • InlineScript { … } is an Activity, so it can be called directly inside the Workflow • If cmdlet is not explicitly excluded, it will implicitly run via InlineScript • Activities cannot use Dynamic Parameters • Activities have common parameters not available on cmdlet counterparts • Some activities can be called remotely without using Invoke-Command

  6. Automatic Parameters -AsJob: Workflow Jobs -ComputerName: Invoke workflows remotely -PSPersist: Instructs Workflow engine to persist Workflow data to disk -PSComputerName: The name of the remote computer(s) to execute the Workflow on -PSConfigurationName: Optionally specify an alternate PSSession Configuration -PSConnectionRetryCount: Number of times that a remote connection will be attempted -PSConnectionRetryIntervalSec: Interval, in seconds, to delay connection retries -PSCredential: The credential that will be used to create remote connections -PSElapsedTimeoutSec: The maximum length of time that the Workflow should run

  7. Workflow Persistence • Workflows are persisted to disk (by default)under: %LocalAppData%\Microsoft\Windows\PowerShell\WF\PS\default • How do I persist a workflow? • Checkpoint-Workflow • -PSPersistparameter • Suspend-Workflow • Use checkpoints sparingly for performance • Suspend-Workflow returns a PSWorkflowJob (even if -AsJob not specified)

  8. Workflow Persistence • V.xml = Version of .NET Framework, Compression, Encryption • Def\VD.xaml = XAML representation of Workflow • Other files are compressed in a binary format, and are not human-readable XAML = eXtensible Application Markup Language

  9. InlineScript InlineScript { } Begin InlineScript { } End Workflow Process Workflow Process • Runs in a separate process by default • Override this behavior by using a custom PSSession Configuration • Activities must use named (not positional) parameters (prior to PowerShell v4) • PowerShell commands inside InlineScript { … } are exempt • Try .. Catch blocks work directly inside of Workflow • Try .. Catch only catches terminating errors (not non-terminating errors)

  10. Workflow: Parallel Tasks Use Parallel { … } inside of a Workflow to run Activities in parallel You can use multiple Parallel { … } blocks in a single Workflow Use Sequence { … }inside of a Parallel { … } block to run activities sequentially Use the ForEach -Parallel statement inside of a Workflow

  11. Workflow Execution Options • New-PSWorkflowExecutionOption (creates custom PSSession configuration) • Encryption • Max persistence store size (in GB) • Path to persisted Workflow store • Allow specific activities • PSSession timeout (after Workflow is suspended)

  12. Workflow Debugging Client(PowerShell 4.0) Server(PowerShell 4.0) Command Variable Line Breakpoints: Limitations Cannot debug nested workflows Cannot debug inside of individual activities Cannot debug Workflows executed as PowerShell background jobs MSDN – Debugging PowerShell Workflows

  13. Resources • Hey, Scripting Guy! Blog from Microsoft • Richard Siddaway has a Workflow series from late 2012 http://goo.gl/f6sU3B • Help about_Workflows • Help about_WorkflowCommonParameters • Help about_Remote*

  14. Contact pcgeek86@gmail.com tsullivan@projectleadership.net http://trevorsullivan.net http://projectleadership.net/blogs.php http://twitter.com/pcgeek86

More Related