0

Below is the file (highly simplified versions) of interest:

main-func.psm1:

function main-func
{
    [CmdletBinding()]
    param 
    ()

    Write-Verbose "In main-func"
    main-workflow
}

workflow main-workflow
{
    [CmdletBinding()]
    param 
    ()

    Write-Verbose "In main-workflow"
    func-outer
}

function func-outer
{
    [CmdletBinding()]
    param
    ()

    Write-Verbose "In func-outer"
    func-inner
}

function func-inner
{
    [CmdletBinding()]
    param
    ()

    Write-Verbose "In func-inner"
}

Export-ModuleMember -function main-func

Now I open Windows Powershell and execute the following commands:

> Import-Module .\main-func.psm1
> main-func -Verbose

The output that I get is as below:

VERBOSE: In main-func
VERBOSE: [localhost]:In main-workflow
VERBOSE: [localhost]:In func-outer
The term 'func-inner' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (func-inner:String) [func-outer], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,func-outer
    + PSComputerName        : [localhost]

But if I replace main-workflow in function main-func with func-outer, then it works.

I'm pretty new to Powershell and Workflows and using workflows is a requirement. Can somebody please explain what's wrong here?

bittusarkar
  • 6,247
  • 3
  • 30
  • 50
  • Have a look at [PowerShell Workflows: Restrictions](http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx). I think you will find the reason there. – Jan Chrbolka May 25 '15 at 06:38
  • I checked but I could not find any obvious issues. – bittusarkar May 25 '15 at 10:47
  • At the time `func-inner` is called it has not yet been declared. – Matt May 25 '15 at 11:25
  • 2
    @Matt When `Export-ModuleMember -function main-func` runs all functions have been created. That's all that matters. – beatcracker May 25 '15 at 11:41

0 Answers0