1

If I have the following code, is it possible to pass the collection of parameters passed to New-AutomationVM to the inner Deploy workflow without individually specifying them.

New-AutomationVM is likely to have ~20 parameters, and that is going to be a considerable piece of code to then integrate into a second internal workflow. (that seems vulnerable to errors)

Is there a better way? (I'm sure at some point I've read about all parameters being included in a psobject style variable, but I can't find a reference to it any more)

workflow New-AutomationVM
{
    Param($var1,$var2)
    workflow Pre-DeploymentChecks
    { Write-Output $true }

    workflow Deploy 
    {
        Param($var1,$var2)
        $checkResult = Pre-DeploymentChecks 
    }

    Deploy -var1 $var1 -var2 $var2 
}
New-AutomationVM -var1 "var1" -var2 "var2" 

1 Answer 1

1

Not as far as I know. The usual solution would be Deploy @PSBoundParameters, but neither $PSBoundParameters or splatting are availble in a workflow.

Splatting is not permitted in workflow activities or in calls to workflows.

Source: Technet

All Windows PowerShell automatic variables are valid in workflows, except for the automatic variables in the following list. For a complete list of automatic variables, see about_Automatic_Variables.

•$Args

•$Error

•$MyInvocation

•$PID

$PSBoundParameters

•$PsCmdlet

•$PSCommandPath

•$PSScriptRoot

•$StackTrace

Source: Technet

Sign up to request clarification or add additional context in comments.

1 Comment

$PSBoundParameters does not work within workflows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.