Your SlideShare is downloading. ×
PowerShell 3.0 workflows
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

PowerShell 3.0 workflows

1,777
views

Published on

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

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

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,777
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
45
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Start with this example; show how long it takes
  • Convert the previous example to workflow and show the improvements and ease in achieving the same.Import-Module PSWorkflowWorkflow Invoke-WorkFlowPing { param( [string[]]$Computers ) foreach -parallel ($computer in $computers) { Test-Connection -ComputerName $computer -Count 1 -EA SilentlyContinue }}Measure-Command -Expression { Invoke-WorkFlowPing -Computers $computers }
  • Relate the earlier example to activities and call out what is an activity in that caseTalk about how the earlier examples achieves all the characteristics defined in slide 6 without any additional scripting from our side.Each Activity runs in its own runspace; talk about variable sharing limitations, etc
  • Show a quick glance at Visual Studio Workflow Authoring
  • # Workflow provides built-in parameters that help in remote execution (Example: PS ComputerName)# Provide suspend, resume capability; checkpoints can be created in a workflow so that the workflow can be resumed from the persisted task# retry connections when the managed nodes are unavailable or can be asked to retry a task if the remote system was offline during workflow execution# You can connect and disconnect to a computer to monitor the workflows running on the computer# use triggers to invoke a workflow!Explain the use cases around these a bit such a complex device monitoring and reporting; multi-tier application deployment; cloud scale-up and scale-out scenarios, etc
  • It is important to understand the Workflow environment before starting to write workflows! So, here it is.Demonstrate the 3 scenarios and configuring workflow environment for 3 scenarios# PS remoting is enabled on domain joined Server 2012 computers, by default.Discuss what happens when we enable PS Remoting on WMF 3.0 systems: # Session Configuration for Workflows is created # SharedHost mode is enabled # Performance optimizations such as background jobs, throttling, lifecycle of remote connectionsDemonstrate how we can get session configuration details and create a custom session configuration
  • Begin with the workflow keyword, which identifies a workflow command to Windows PowerShell. The workflow keyword is required in a scriptworkflow. The name of the workflow follows the workflow keyword. The body of the workflow is enclosed in braces.Cmdlets that have no implementation as activities:New-AliasShow-CommandSet-PSBreakPointFormat-ListEnter-PSSessionGet-Variable
  • Talk about the activity common parameters and show examples!
  • Talk about the parallel activities and what happens when this workflow is run and describe that the order is not guranteed.
  • Should be combined with Parallel to be more effective. Otherwise, this is nothing different than listing all activities in an order.
  • Just a quick demo of these features or benefits
  • Transcript

    • 1. PowerShell Bangaloreand ITPro User Groups In-person Meeting – 15th, December 2012 http://twitter.com/BangaloreITPr o http://twitter.com/psbug LearningPowerShell.com
    • 2. PowerShell 3.0 WorkflowsPowerShell Bangalore User Group (@PSBUG) – 15th December, 2012 Ravikanth Chaganti http://twitter.com/ravikanth http://ravichaganti.com/blog LearningPowerShell.com
    • 3. About Me• Work at Dell Inc.• PowerShell MVP since 2010• Author • Layman’s guide to PS remoting • WQL via PowerShell• Founder & Editor • PowerShellMagazine.co m • LearningPowerShell.com (coming soon) LearningPowerShell.com
    • 4. PS WorkflowsImage courtesy: http://ebsindy.com/wp-content/uploads/2012/05/web-pg-1-br-pg-1.jpg LearningPowerShell.com
    • 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 }} LearningPowerShell.com
    • 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! LearningPowerShell.com
    • 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 LearningPowerShell.com
    • 8. Introduction to Workflows• PowerShell Workflows are based on Windows Workflow Foundation (WWF)• Can be authored using – PowerShell syntax – XAML files (Visual Studio) LearningPowerShell.com
    • 9. Benefits of Workflows• Multi-device management• Automated failure recovery• Connection and activity retries• Connect and disconnect• Task Scheduling LearningPowerShell.com
    • 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: http://technet.microsoft.com/en-us/library/jj134257.aspx LearningPowerShell.com
    • 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 LearningPowerShell.com
    • 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}} LearningPowerShell.com
    • 13. Activities in Parallelworkflow Test-Workflow{ Parallel { <Activity> <Activity> }}Foreach –Parallel and Parallel Keywords are used LearningPowerShell.com
    • 14. Activities in Sequenceworkflow Test-Workflow{ sequence { <Activity3> <Activity4> ... }} LearningPowerShell.com
    • 15. Nested Workflows• Workflows can be nested and combined with functions! – Increases complexity• Recursive calling is not allowed LearningPowerShell.com
    • 16. Quick Bytes on benefits• Suspend / Resume Workflows• Restart computer in a workflow – Manual – Automatic resume using Scheduled Jobs• Checkpoints or persisting workflow data LearningPowerShell.com
    • 17. References• Getting Started with Windows PowerShell Workflows: http://technet.microsoft.com/en-us/library/jj134242• Windows Workflows (video) by Bruce Payette: http://youtu.be/qeV4Qmce2Dk• PowerShell Team Blog: – http://blogs.msdn.com/b/powershell/archive/2012/03/17/when- windows-powershell-met-workflow.aspx – http://blogs.msdn.com/b/powershell/archive/2012/06/15/high- level-architecture-of-windows-powershell-workflow-part-1.aspx – http://blogs.msdn.com/b/powershell/archive/2012/06/19/high- level-architecture-of-windows-powershell-workflow-part-2.aspx LearningPowerShell.com
    • 18. Call to Action• Join our FB Page: https://www.facebook.com/groups/451930394834695/• 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! (http://psbug.wordpress.com/) LearningPowerShell.com
    • 19. OPEN HOUSE LearningPowerShell.com

    ×