Automation

 View Only
  • 1.  parallel Execution using Powershell

    Posted Aug 02, 2022 12:20 PM

    I am working on a activity which needs to get uptime from several servers. I am using Invoke-vmscript to do this activity. I want to use Parallel processing to reduce time.

    Without a new ps session and using jobs. Is there any other way to do parallel execution.

    I have tried Foreach-object -parallel, this didnot work because my powershell version is not 7.

    Any suggestion Helps!

    Thanks in advance



  • 2.  RE: parallel Execution using Powershell

    Posted Aug 02, 2022 12:51 PM

    If your PS is not PSv7 and you don't want to use Start-Job, then the other option is to look at runspaces.
    But be aware that PowerCLI is not threadsafe.



  • 3.  RE: parallel Execution using Powershell

    Posted Aug 02, 2022 12:56 PM

    HI LucD,

    Can you help me, by using jobs.
    I had to run a script which is large on multiple servers. Can you help me with using Jobs.

    Thanks in advance

     



  • 4.  RE: parallel Execution using Powershell
    Best Answer

    Posted Aug 02, 2022 01:17 PM


  • 5.  RE: parallel Execution using Powershell

    Posted Aug 02, 2022 01:48 PM

    Hi LucD,
    I got this warning in the job output. Can you help me with this.

    WARNING: Please consider joining the VMware Customer Experience Improvement Program, so you can help us make PowerCLI a better product. You can join using the following c
    ommand:

    Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true

    VMware's Customer Experience Improvement Program ("CEIP") provides VMware with information that enables VMware to improve its products and services, to fix problems, and
    to advise you on how best to deploy and use our products. As part of the CEIP, VMware collects technical information about your organization’s use of VMware products a
    nd services on a regular basis in association with your organization’s VMware license key(s). This information does not personally identify any individual.

    For more details: type "help about_ceip" to see the related help article.

    To disable this warning and set your preference use the following command and restart PowerShell:
    Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true or $false.



  • 6.  RE: parallel Execution using Powershell

    Posted Aug 02, 2022 02:17 PM

    That is a normal warning, just execute the command on the last line with either $true or $false.
    You are setting up a new environment, hence this warning.



  • 7.  RE: parallel Execution using Powershell

    Posted Aug 02, 2022 02:47 PM

    Thanks much for reply.
    I want to send a Another variable to Argument list. So that it should Take the variable data in to code block.
    Like I want to pass multiple variables to arugementlist. 
    Is this possible?
    I want to run a code block for multiple servers to fetch data.
    $vmnames |%{
    $scriptblock = { #code}
    Start-Job $ScriptBlock -ArgumentList $_
    }
    This way i am using the code block. 



  • 8.  RE: parallel Execution using Powershell

    Posted Aug 02, 2022 02:55 PM

    If you read that thread I pointed to earlier, you'll notice it also discusses passing an array.
    Also, in that thread I point to an example on my blog where we pass 3 arguments to the job.



  • 9.  RE: parallel Execution using Powershell

    Posted Aug 03, 2022 01:04 PM

    you basically have the answer, just install the PowerShell 7 and get the job done,

    and you don't have to worried about the warning,  just run the below command and be done with it.
    Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP:$false