A workflow cannot use recursion

This topic contains 4 replies, has 2 voices, and was last updated by  David Zemdegs 1 week, 2 days ago.

  • Author
    Posts
  • #80423

    David Zemdegs
    Participant

    I have the code below which has been fine until I installed V5.1 of PS. Now everytime I load the module with this code I get the recursion error. Cant figure out why it has changed...

    Workflow Test-WFConnection {
    
        # Run multiple parallel "pings" so it runs quicker
    
      param(
        [string[]]$Computers
      )
    
      foreach -parallel ($computer in $computers) {
    
          [pscustomobject]@{
            Computer = $computer
            Reachable = (Test-Connection -ComputerName $computer -Count 1 -Quiet)
          }
      }
    }
    
  • #80575

    Richard Siddaway
    Moderator

    I ran your code in a Windows 2016 domain – PowerShell 5.1 – and it worked.

    Test-Connection uses the Win32_PingStatus WMI class and requires a DCOM connection to the remote machine. I'd suggest testing Test-Connection against one of the failing remote machines directly rather than in the workflow. I'd also suggest that you test get-WMIObject against the failing machine to help determine if there is a DCOM issue

    • #80644

      David Zemdegs
      Participant

      The code works. The problem is that when I load the module that has the above code in it I get the 'A workflow cannot use recursion' error. Don't know its giving me that error when the code actually works.

  • #80741

    Richard Siddaway
    Moderator

    Do you call the workflow within the module code?

  • #81637

    David Zemdegs
    Participant

    No – the module is imported at the start of an external script and the workflow is launched from there.
    This code has not changed – it just started showing this 'error' since V5 or 5.1 of WMF.

You must be logged in to reply to this topic.