none
Calling functions from WorkFlow fails RRS feed

  • Question

  • Hello,

    There is a function which checks the port status, I was planning to run it against hundred of servers and save the result in table. Using the old school foreach it always takes so much time, so I went for using Workflow. However it seems it is not possible to call functions inside the workflow. Every time the function is called from workflow, it throws the error indicating "I do not know BLA BLA function or cmdlet..".

    Here is the structure:

    Function Test-Port {}
    
    Workflow check
       {
         foreach -parallel ($DC in $DCs)
         {
           $Result = Test-Port 88 ...
    
         }
    
       }
    

    So far:

    • I tried using InlineScript, no result.
    • I tried moving the function inside the workflow, no result.
    • I tried creating the function inside each instance of workflow (right after for-each), no result

    Any other way that you might think of? 

    The reason that I am intrested in using workflows is that firstly there are so many servers, secondly there are so many ports. 


    Mahdi Tehrani | | www.mahditehrani.ir
    Make sure to download my free PowerShell scripts:


    • Edited by Mahdi Tehrani Monday, March 25, 2019 6:42 PM
    • Moved by Bill_Stewart Wednesday, September 4, 2019 7:21 PM Abandoned
    Monday, March 25, 2019 3:43 PM

All replies

  • Function Test-Port($dc) {
       $dc
    }
    
    Workflow check {
        $dcs = 1,2,3,4,5
        foreach -parallel ($dc in $dcs) {
            Test-Port $dc   
        }
    }
    


    \_(ツ)_/

    Monday, March 25, 2019 4:11 PM