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
There is a sample in Solved: Re: Pass vCenter connection to a Job - VMware Technology Network VMTN
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
There is a sample in Solved: Re: Pass vCenter connection to a Job - VMware Technology Network VMTN
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
✌️