PowerShell – Workflows

Reference material:
http://technet.microsoft.com/en-us/library/jj134242.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx

Import-Module PSWorkflow

workflow Test-WorkflowInline{
    InlineScript{
        $object = New-Object -TypeName PSObject
        $object | Add-Member -MemberType NoteProperty `
                -Name ExampleProperty `
                -Value 'Hello!'
        $object | Get-Member
    }
    # The $object variable no longer exists at this point as it has left the InlineScript block.
    #The below line fails if uncommented.
    # $object |Get-Member
}

workflow Test-WorkflowParallel{
    "This line will always run first!"
    parallel {
        "Command One."
        "Command Two."

        sequence{
            "Command Alpha."
            "Command Beta."
        }
    }
}

# Possible output from Test-WorkflowParallel:
# This line will always run first!
# Command One.
# Command Alpha.
# Command Beta.
# Command Two.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s