+ All Categories
Home > Technology > PowerShell 3.0 workflows

PowerShell 3.0 workflows

Date post: 11-Nov-2014
Category:
Upload: ravikanth-chaganti
View: 2,438 times
Download: 1 times
Share this document with a friend
Description:
This slide deck was used for the Windows PowerShell 3.0 Workflows session at the Bangalore IT Pro user group.
Popular Tags:
19
LearningPowerShell.com PowerShell Bangalore and ITPro User Groups In-person Meeting – 15 th , December 2012 http://twitter.com/ psbug http://twitter.com/ BangaloreITPro
Transcript
Page 1: PowerShell 3.0 workflows

LearningPowerShell.com

PowerShell Bangalore and ITPro User Groups

In-person Meeting – 15th, December 2012

http://twitter.com/psbug

http://twitter.com/BangaloreITPro

Page 2: PowerShell 3.0 workflows

LearningPowerShell.com

PowerShell 3.0 Workflows

Ravikanth Chaganti

PowerShell Bangalore User Group (@PSBUG) – 15th December, 2012

http://twitter.com/ravikanth

http://ravichaganti.com/blog

Page 3: PowerShell 3.0 workflows

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.c

om• LearningPowerShell.c

om (coming soon)

Page 4: PowerShell 3.0 workflows

LearningPowerShell.comImage courtesy: http://ebsindy.com/wp-content/uploads/2012/05/web-pg-1-br-pg-1.jpg

PS Workflows

Page 5: PowerShell 3.0 workflows

LearningPowerShell.com

Introduction to Workflows

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

Let us start with an example!

Page 6: PowerShell 3.0 workflows

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!

Page 7: PowerShell 3.0 workflows

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

Page 8: PowerShell 3.0 workflows

LearningPowerShell.com

Introduction to Workflows

• PowerShell Workflows are based on Windows Workflow Foundation (WWF)

• Can be authored using – PowerShell syntax– XAML files (Visual Studio)

Page 9: PowerShell 3.0 workflows

LearningPowerShell.com

Benefits of Workflows

• Multi-device management• Automated failure recovery• Connection and activity retries• Connect and disconnect• Task Scheduling

Page 10: PowerShell 3.0 workflows

LearningPowerShell.com

Workflow Environment

Source: http://technet.microsoft.com/en-us/library/jj134257.aspx

Workflow ClientComputer used for managing or viewing workflows

Workflow ServerComputer used for running workflows

Managed NodeComputer on which actions or activities are performed

Page 11: PowerShell 3.0 workflows

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

Page 12: PowerShell 3.0 workflows

LearningPowerShell.com

Writing a Workflowworkflow Test-Workflow{

Get-Process -Name PowerShellGet-WindowsFeature -Name PowerShell, PowerShell-v2InlineScript { 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}}

Page 13: PowerShell 3.0 workflows

LearningPowerShell.com

Activities in Parallel

workflow Test-Workflow{

Parallel{

<Activity><Activity>

}}

Foreach –Parallel and Parallel Keywords are used

Page 14: PowerShell 3.0 workflows

LearningPowerShell.com

Activities in Sequence

workflow Test-Workflow{

sequence{

<Activity3><Activity4>...

}}

Page 15: PowerShell 3.0 workflows

LearningPowerShell.com

Nested Workflows

• Workflows can be nested and combined with functions!– Increases complexity

• Recursive calling is not allowed

Page 16: PowerShell 3.0 workflows

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

Page 17: PowerShell 3.0 workflows

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

Page 18: PowerShell 3.0 workflows

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/)

Page 19: PowerShell 3.0 workflows

LearningPowerShell.com

OPEN HOUSE


Recommended