none
how to set foreach -throttlelimit RRS feed

  • Question

  • I have a simple script that uses a workflow with a foreach (with the opitons -parrallel -throttlelimit ). When I run my script at most I only see 5 instances of my workflow runing at one time, now matter what I set the throttlelimit to. Is this throttlelimit limited to a max of 5?

    My code looks like:

     

    workflow testSessions {
    param(
          [string]$server,
          [string]$user,
          [string]$password,
          [string[]]$runThisManyThreads,
          [int]$throttle = 8

       )
       foreach -parallel -throttlelimit $throttle ($item in $runThisManyThreads) {    
       $rc = InlineScript {

       .... do some stuff here ...

    }

    testSessions $cloudVM $cloudVMUser $cloudVMPass $howManyTreads

    • Moved by Bill_Stewart Thursday, December 13, 2018 3:24 PM Abandoned
    Wednesday, September 19, 2018 10:32 PM

All replies

  • Syntax error!

    workflow testSessions {
        param(
           [string]$server,
           [string]$user,
           [string]$password,
           [array]$runThisManyThreads,
           [int]$throttle = 8
        )
        
        foreach -parallel -throttlelimit $throttle ($item in $runThisManyThreads) {    
            InlineScript {
                'Hello World'
            }
        }
    }
    testSessions -runThisManyThreads (1..50)


    \_(ツ)_/

    Wednesday, September 19, 2018 10:43 PM
  • So I tried out your changes but it isn't really not doing what I want it to do. When I modify the code in the InlineScript block to actually connect to a server and run some commands on the server. I only see 5 instances of that code running at one time. I even had the code put time stamps into a file and I can see that 5 are doing the operations in parallel and the others haven't started.
    Thursday, September 20, 2018 4:18 PM