locked
Runspaces and SQLPS module RRS feed

  • Question

  • Hi. 

    I using powershell 2.0 and i start write test paralle commands executing with Runspaces instead of Jobs.

    I try load sqlps module in differents runspaces, same time.

    The powershell trhows erros of type:

    Collection was modified; enumeration operation may not execute.
    Collection was modified; enumeration operation may not execute.
    Collection was modified; enumeration operation may not execute.
    Collection was modified; enumeration operation may not execute.

    Also, any cmdlet from the module called, procude this error:

    The WriteObject and WriteError methods cannot be called from outside the
    overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and
    only from that same thread. Validate that the cmdlet makes these calls correctly, or please contact Microsoft Support Services.

    Somene knows that whats happens?


    []'s | Rodrigo Ribeiro Gomes | MCTS/MCITP Dev/DBA

    Thursday, October 16, 2014 9:56 PM

All replies

  • Hi RodrigoRRG,

    Would you please also post the current script to help us to troubleshoot?

    In addition, Have you checked this function? which can help you to run script in paralle:

    ForEach-Parallel:

    http://powertoe.wordpress.com/2012/05/03/foreach-parallel/

    Best Regards,

    Anna Wang

    Friday, October 17, 2014 9:58 AM
  • Hi AnnaWY, thanks for you reply.

    I tried execute just the code "import-module sqlps" with the Foreach-Paralle and this errors presented to me.

    I guess this errors is because the sqlps module is not thread safe.


    []'s | Rodrigo Ribeiro Gomes | MCTS/MCITP Dev/DBA

    Saturday, October 18, 2014 3:34 AM