SlideShare a Scribd company logo
1 of 19
PowerShell Bangalore
and ITPro User Groups
      In-person Meeting – 15th, December 2012



                    http://twitter.com/BangaloreITPr
                    o
                    http://twitter.com/psbug




                               LearningPowerShell.com
PowerShell 3.0
                        Workflows
PowerShell Bangalore User Group (@PSBUG) – 15th December,
                                                    2012




                                         Ravikanth Chaganti
                                     http://twitter.com/ravikanth

                                     http://ravichaganti.com/blog


                                            LearningPowerShell.com
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
PS Workflows




Image courtesy: http://ebsindy.com/wp-content/uploads/2012/05/web-pg-1-br-pg-1.jpg   LearningPowerShell.com
Introduction to Workflows
Let us start with an example!

#Test Computer Connectivity
$computers = Get-Content computers.txt
$computers.Count
Measure-Command -Expression {
    foreach ($computer in $computers) {
        Test-Connection -ComputerName $computer -Count 1 -EA
SilentlyContinue
    }
}




                                                  LearningPowerShell.com
Introduction to Workflows
     • Simple example but can be a long-running task!
     • How can we make this:
        • Repeatable
        • Parallelizable
        • Interruptible
        • Stoppable and Restartable

We 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
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
Introduction to Workflows
• PowerShell Workflows are based on
  Windows Workflow Foundation (WWF)
• Can be authored using
  – PowerShell syntax
  – XAML files (Visual Studio)




                                 LearningPowerShell.com
Benefits of Workflows
•   Multi-device management
•   Automated failure recovery
•   Connection and activity retries
•   Connect and disconnect
•   Task Scheduling




                                      LearningPowerShell.com
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 performed




Source: http://technet.microsoft.com/en-us/library/jj134257.aspx                   LearningPowerShell.com
Writing a Workflow
Workflow 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
Writing a Workflow
workflow 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 no
workflow activity implementation or for the dynamic
parameters!
workflow Test-Workflow
{
       InlineScript {Get-ChildItem -Path Cert:CurrentUser -
CodeSigningCert}
}

                                                 LearningPowerShell.com
Activities in Parallel
workflow Test-Workflow
{
       Parallel
       {
              <Activity>
              <Activity>
       }
}


Foreach –Parallel and Parallel Keywords are used



                                             LearningPowerShell.com
Activities in Sequence
workflow Test-Workflow
{
       sequence
       {
              <Activity3>
              <Activity4>
              ...
       }
}




                                 LearningPowerShell.com
Nested Workflows
• Workflows can be nested and combined
  with functions!
  – Increases complexity
• Recursive calling is not allowed




                                     LearningPowerShell.com
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
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
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
OPEN HOUSE


             LearningPowerShell.com

More Related Content

What's hot

What's hot (20)

Intro to Service Worker API and its use cases
Intro to Service Worker API and its use casesIntro to Service Worker API and its use cases
Intro to Service Worker API and its use cases
 
Life in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with djangoLife in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with django
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul Jones
 
Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!
 
Features, Exportables & You
Features, Exportables & YouFeatures, Exportables & You
Features, Exportables & You
 
High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010
 
Release Management with Visual Studio Team Services and Office Dev PnP
Release Management with Visual Studio Team Services and Office Dev PnPRelease Management with Visual Studio Team Services and Office Dev PnP
Release Management with Visual Studio Team Services and Office Dev PnP
 
Riga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous IntegrationRiga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous Integration
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
 
Module bundling v module loading
Module bundling v module loadingModule bundling v module loading
Module bundling v module loading
 
CollabSphere 2018 - Java in Domino After XPages
CollabSphere 2018 - Java in Domino After XPagesCollabSphere 2018 - Java in Domino After XPages
CollabSphere 2018 - Java in Domino After XPages
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
ProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applicationsProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applications
 
React Component Library Design @WalmartLabs
React Component Library Design @WalmartLabsReact Component Library Design @WalmartLabs
React Component Library Design @WalmartLabs
 
DanNotes XPages Mobile Controls
DanNotes XPages Mobile ControlsDanNotes XPages Mobile Controls
DanNotes XPages Mobile Controls
 
JavaLand - Integration Testing How-to
JavaLand - Integration Testing How-toJavaLand - Integration Testing How-to
JavaLand - Integration Testing How-to
 
A simple workflow system using state machines
A simple workflow system using state machinesA simple workflow system using state machines
A simple workflow system using state machines
 

Viewers also liked (7)

Share Point2010 Quick Snack Ravikanth Chaganti
Share Point2010 Quick Snack Ravikanth ChagantiShare Point2010 Quick Snack Ravikanth Chaganti
Share Point2010 Quick Snack Ravikanth Chaganti
 
Managing Hyper-V With PowerShell
Managing Hyper-V With PowerShellManaging Hyper-V With PowerShell
Managing Hyper-V With PowerShell
 
SharePoint 2010 Beta Technical Overview
SharePoint 2010 Beta Technical OverviewSharePoint 2010 Beta Technical Overview
SharePoint 2010 Beta Technical Overview
 
Blooming SharePoint Design
Blooming SharePoint DesignBlooming SharePoint Design
Blooming SharePoint Design
 
Power shell saturday ravikanth
Power shell saturday  ravikanthPower shell saturday  ravikanth
Power shell saturday ravikanth
 
Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell Scripting
 
PowerShell DSC Partial Configurations and Cross-node Synchronization
PowerShell DSC Partial Configurations and Cross-node SynchronizationPowerShell DSC Partial Configurations and Cross-node Synchronization
PowerShell DSC Partial Configurations and Cross-node Synchronization
 

Similar to PowerShell 3.0 workflows

PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
Bryan Cafferky
 
PowerShell for SharePoint Admins
PowerShell for SharePoint AdminsPowerShell for SharePoint Admins
PowerShell for SharePoint Admins
Rick Taylor
 

Similar to PowerShell 3.0 workflows (20)

Intro to PowerShell Workflow
Intro to PowerShell WorkflowIntro to PowerShell Workflow
Intro to PowerShell Workflow
 
Travis Wright - PS WF SMA SCSM SP
Travis Wright - PS WF SMA SCSM SPTravis Wright - PS WF SMA SCSM SP
Travis Wright - PS WF SMA SCSM SP
 
Sql Server & PowerShell
Sql Server & PowerShellSql Server & PowerShell
Sql Server & PowerShell
 
System Center Universe Europe 2014 - Jakob Gottlieb Svendsen - Service Manag...
System Center Universe Europe 2014 - Jakob Gottlieb Svendsen -  Service Manag...System Center Universe Europe 2014 - Jakob Gottlieb Svendsen -  Service Manag...
System Center Universe Europe 2014 - Jakob Gottlieb Svendsen - Service Manag...
 
Automation 2.0 - Automation Tools for Hybrid Cloud Environments
Automation 2.0 - Automation Tools for Hybrid Cloud EnvironmentsAutomation 2.0 - Automation Tools for Hybrid Cloud Environments
Automation 2.0 - Automation Tools for Hybrid Cloud Environments
 
Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010
 
Enhanced Workflows in Cascade Server by Leah Einecker
Enhanced Workflows in Cascade Server by Leah EineckerEnhanced Workflows in Cascade Server by Leah Einecker
Enhanced Workflows in Cascade Server by Leah Einecker
 
Azure automation
Azure automationAzure automation
Azure automation
 
Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
 
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
 
Java workflow engines
Java workflow enginesJava workflow engines
Java workflow engines
 
08_Workflows.ppt
08_Workflows.ppt08_Workflows.ppt
08_Workflows.ppt
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL
 
PowerShell for SharePoint Admins
PowerShell for SharePoint AdminsPowerShell for SharePoint Admins
PowerShell for SharePoint Admins
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Power Shell For Testers
Power Shell For TestersPower Shell For Testers
Power Shell For Testers
 
North east user group tour
North east user group tourNorth east user group tour
North east user group tour
 
Advantages of Rails Framework
Advantages of Rails FrameworkAdvantages of Rails Framework
Advantages of Rails Framework
 

More from Ravikanth Chaganti

Desired state-configuration-ravikanth-august-2013-vtc india
Desired state-configuration-ravikanth-august-2013-vtc indiaDesired state-configuration-ravikanth-august-2013-vtc india
Desired state-configuration-ravikanth-august-2013-vtc india
Ravikanth Chaganti
 

More from Ravikanth Chaganti (20)

Azure Bicep - An Introduction
Azure Bicep - An IntroductionAzure Bicep - An Introduction
Azure Bicep - An Introduction
 
Azure CLI 2.0 Tips and Tricks
Azure CLI 2.0 Tips and TricksAzure CLI 2.0 Tips and Tricks
Azure CLI 2.0 Tips and Tricks
 
Tests Driven PowerShell Learning
Tests Driven PowerShell LearningTests Driven PowerShell Learning
Tests Driven PowerShell Learning
 
PowerShell Data as File System
PowerShell Data as File SystemPowerShell Data as File System
PowerShell Data as File System
 
Azure at the command line
Azure at the command lineAzure at the command line
Azure at the command line
 
Microsoft Azure Cloud and DevOps
Microsoft Azure Cloud and DevOpsMicrosoft Azure Cloud and DevOps
Microsoft Azure Cloud and DevOps
 
Using PowerShell DSC with AWS Cloud and CloudFormation
Using PowerShell DSC with AWS Cloud and CloudFormationUsing PowerShell DSC with AWS Cloud and CloudFormation
Using PowerShell DSC with AWS Cloud and CloudFormation
 
Developing Infrastructure Code for CI & CD
Developing Infrastructure Code for CI & CDDeveloping Infrastructure Code for CI & CD
Developing Infrastructure Code for CI & CD
 
Operations Validation for Infrastructure As Code - PSConfEU 2016
Operations Validation for Infrastructure As Code - PSConfEU 2016Operations Validation for Infrastructure As Code - PSConfEU 2016
Operations Validation for Infrastructure As Code - PSConfEU 2016
 
Authoring Azure Resource Manager Templates - Future Unleashed 2015
Authoring Azure Resource Manager Templates - Future Unleashed 2015Authoring Azure Resource Manager Templates - Future Unleashed 2015
Authoring Azure Resource Manager Templates - Future Unleashed 2015
 
Cloud Computing for IT professionals
Cloud Computing for IT professionalsCloud Computing for IT professionals
Cloud Computing for IT professionals
 
Introduction to Microsoft Azure Compute
Introduction to Microsoft Azure ComputeIntroduction to Microsoft Azure Compute
Introduction to Microsoft Azure Compute
 
Cross platform configuration management using Desired State Configuration
Cross platform configuration management using Desired State ConfigurationCross platform configuration management using Desired State Configuration
Cross platform configuration management using Desired State Configuration
 
Windows Server 2012 R2 Hyper-V Replica
Windows Server 2012 R2 Hyper-V ReplicaWindows Server 2012 R2 Hyper-V Replica
Windows Server 2012 R2 Hyper-V Replica
 
Whats new in Windows Server 2012 R2 Hyper-V
Whats new in Windows Server 2012 R2 Hyper-VWhats new in Windows Server 2012 R2 Hyper-V
Whats new in Windows Server 2012 R2 Hyper-V
 
Configuration management comes to Windows
Configuration management comes to WindowsConfiguration management comes to Windows
Configuration management comes to Windows
 
Desired state-configuration-ravikanth-august-2013-vtc india
Desired state-configuration-ravikanth-august-2013-vtc indiaDesired state-configuration-ravikanth-august-2013-vtc india
Desired state-configuration-ravikanth-august-2013-vtc india
 
PowerShell in the enterprise - TechED India 2011
PowerShell in the enterprise - TechED India 2011PowerShell in the enterprise - TechED India 2011
PowerShell in the enterprise - TechED India 2011
 
Using PowerShell for active directory management
Using PowerShell for active directory managementUsing PowerShell for active directory management
Using PowerShell for active directory management
 
PowerShell for sharepoint 2010 administrators
PowerShell for sharepoint 2010 administratorsPowerShell for sharepoint 2010 administrators
PowerShell for sharepoint 2010 administrators
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

PowerShell 3.0 workflows

  • 1. PowerShell Bangalore and ITPro User Groups In-person Meeting – 15th, December 2012 http://twitter.com/BangaloreITPr o http://twitter.com/psbug LearningPowerShell.com
  • 2. PowerShell 3.0 Workflows PowerShell 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 Workflows Image courtesy: http://ebsindy.com/wp-content/uploads/2012/05/web-pg-1-br-pg-1.jpg LearningPowerShell.com
  • 5. Introduction to Workflows Let us start with an example! #Test Computer Connectivity $computers = Get-Content computers.txt $computers.Count Measure-Command -Expression { foreach ($computer in $computers) { Test-Connection -ComputerName $computer -Count 1 -EA SilentlyContinue } } 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 Restartable We 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 performed Source: http://technet.microsoft.com/en-us/library/jj134257.aspx LearningPowerShell.com
  • 11. Writing a Workflow Workflow 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 Workflow workflow 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 no workflow activity implementation or for the dynamic parameters! workflow Test-Workflow { InlineScript {Get-ChildItem -Path Cert:CurrentUser - CodeSigningCert} } LearningPowerShell.com
  • 13. Activities in Parallel workflow Test-Workflow { Parallel { <Activity> <Activity> } } Foreach –Parallel and Parallel Keywords are used LearningPowerShell.com
  • 14. Activities in Sequence workflow 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

Editor's Notes

  1. Start with this example; show how long it takes
  2. 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 }
  3. 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
  4. Show a quick glance at Visual Studio Workflow Authoring
  5. # 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
  6. 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
  7. 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
  8. Talk about the activity common parameters and show examples!
  9. Talk about the parallel activities and what happens when this workflow is run and describe that the order is not guranteed.
  10. Should be combined with Parallel to be more effective. Otherwise, this is nothing different than listing all activities in an order.
  11. Just a quick demo of these features or benefits