Author Posts

April 28, 2014 at 4:46 pm

I have following powershell script:

function Testing
{
    [CmdLetBinding()]
    Param (                
        [int]$MaxRetrycount = 3,
        [Parameter(ValueFromPipeline=$True)] [String]$Definition
    )   
    return $MaxRetrycount
}

workflow Test-Workflow
{
    $PSComputerName

    $data = 'abc','xyz'
    $data | Testing -MaxRetrycount 2 -Definition
    $JobName
}

Test-Workflow

But execution of this script giving me error like


The 'Testing' activity is not supported in a workflow pipeline.

Did I make any mistake in calling function with command pipeline from workflow?

Thanks in advance.

May 8, 2014 at 11:40 am

When a workflow is run in PowerShell, it's processed by Windows Workflow Foundation (WWF) which translates the PowerShell commands into WWF Activities. Since your Testing function doesn't have an equivalent WWF activity, that means it can't be used in a workflow unless it's placed inside of an inline script block.


workflow Test-Workflow {
    $PSComputerName

    $data = 'abc','xyz'

    InlineScript {
        $data | Testing -MaxRetrycount 2
    }

    $JobName
}

Supposedly, the Testing function would need to be in the same script file as the workflow or be placed in a module. I was only able to make it work by placing the Testing function inside of a module that's located in one of the $env:PSModulePath paths that's available to all users, although I didn't spend a lot of time trying to make it work the other way either.