Successfully reported this slideshow.

PowerShell 3.0 workflows


Published on

This slide deck was used for the Windows PowerShell 3.0 Workflows session at the Bangalore IT Pro user group.

Published in: Technology
  • Be the first to comment

PowerShell 3.0 workflows

  1. 1. PowerShell Bangaloreand ITPro User Groups In-person Meeting – 15th, December 2012 o
  2. 2. PowerShell 3.0 WorkflowsPowerShell Bangalore User Group (@PSBUG) – 15th December, 2012 Ravikanth Chaganti
  3. 3. About Me• Work at Dell Inc.• PowerShell MVP since 2010• Author • Layman’s guide to PS remoting • WQL via PowerShell• Founder & Editor • m • (coming soon)
  4. 4. PS WorkflowsImage courtesy:
  5. 5. Introduction to WorkflowsLet us start with an example!#Test Computer Connectivity$computers = Get-Content computers.txt$computers.CountMeasure-Command -Expression { foreach ($computer in $computers) { Test-Connection -ComputerName $computer -Count 1 -EASilentlyContinue }}
  6. 6. Introduction to Workflows • Simple example but can be a long-running task! • How can we make this: • Repeatable • Parallelizable • Interruptible • Stoppable and RestartableWe can use functions, remoting, and background jobs to achieve all the above Involves lot of scripting! Workflows in PowerShell 3.0 is introduced to ease this task!
  7. 7. Introduction to Workflows• A Workflow is a set of activities• An activity is a specific task in a Workflow• Scalable solutions for complex activities – Run in parallel or sequentially – Repeatable – Interruptible and recoverable
  8. 8. Introduction to Workflows• PowerShell Workflows are based on Windows Workflow Foundation (WWF)• Can be authored using – PowerShell syntax – XAML files (Visual Studio)
  9. 9. Benefits of Workflows• Multi-device management• Automated failure recovery• Connection and activity retries• Connect and disconnect• Task Scheduling
  10. 10. Workflow Environment Workflow Client Computer used for managing or viewing workflows Workflow Server Computer used for running workflows Managed Node Computer on which actions or activities are performedSource:
  11. 11. Writing a WorkflowWorkflow Write-Hello { “Hello, World”}• Syntactically similar to PowerShell Functions• Can define parameters & CmdletBinding attribute • No Begin, Process, and End blocks!• Most of the core cmdlets can be added as cmdlets• Other cmdlets implicitly run as InlineScript
  12. 12. Writing a Workflowworkflow Test-Workflow{ Get-Process -Name PowerShell Get-WindowsFeature -Name PowerShell, PowerShell-v2 InlineScript { Get-Variable -Name PSHome }}InlineScript activity is used for cmdlets that have noworkflow activity implementation or for the dynamicparameters!workflow Test-Workflow{ InlineScript {Get-ChildItem -Path Cert:CurrentUser -CodeSigningCert}}
  13. 13. Activities in Parallelworkflow Test-Workflow{ Parallel { <Activity> <Activity> }}Foreach –Parallel and Parallel Keywords are used
  14. 14. Activities in Sequenceworkflow Test-Workflow{ sequence { <Activity3> <Activity4> ... }}
  15. 15. Nested Workflows• Workflows can be nested and combined with functions! – Increases complexity• Recursive calling is not allowed
  16. 16. Quick Bytes on benefits• Suspend / Resume Workflows• Restart computer in a workflow – Manual – Automatic resume using Scheduled Jobs• Checkpoints or persisting workflow data
  17. 17. References• Getting Started with Windows PowerShell Workflows:• Windows Workflows (video) by Bruce Payette:• PowerShell Team Blog: – windows-powershell-met-workflow.aspx – level-architecture-of-windows-powershell-workflow-part-1.aspx – level-architecture-of-windows-powershell-workflow-part-2.aspx
  18. 18. Call to Action• Join our FB Page:• Follow us on Twitter: @psbug• Provide feedback on what you want to see• Watch out for the session schedules!• Write for us! – On PowerShell Magazine – On PSBUG blog! (
  19. 19. OPEN HOUSE