I wonder if someone can help me as I’m confused with the how the output of the following produces what it does. I presume that this is something to do with scopes.
WORKFLOW TEST1 {
$a = 42
Sequence {$b=$a;
$workflow:c = $a
}
“variable a is: [$a]”
“variable b is: [$b]”
“variable c is: [$c]”
}
When I run the above, this is the result I get:
PS C:> Test1
variable a is: [42]
variable b is:
variable c is: [42]
Scopes are not a thing limited to workflows. Scope affects everything. It’s fully documented in the help files and of course all over the web in general.
Anything declared at the top level of the workflow is persisted and is considered “global” to that workflow. You’ve done that with the $workflow: modifier as well. Anything inside an activity is scoped to that activity, such as a Sequence.
Workflows are not PowerShell per se; they run under WWF. So you’re dealing with a whole different set of rules, and they’re not always readily apparent. It’s why I dislike Workflow quite a bit.