VMware Cloud Community
AmolPatil
Enthusiast
Enthusiast
Jump to solution

Multiple VMs Inventory using multitasking process ?

Hello,

I was trying for long to make a script to fetch multiple VMs information from VC(s).

I got success to build a script with desired format and properties BUT this will go one my one ForEach ($vm in$Vms)

Now I am looking for code which will run as a job OR parallel process to fetch the 1000+ VMs information simultaneously to save the time and speedup the process.

Any Hint?

Regards,

Amol Patil

Regards, Amol Patil VCP 5
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

There are many ways to speed up a script.

  • use the Get-VIew cmdlet instead of the regular PowerCLI cmdlets.
  • use parallelism
    • with Start-Job you can run a script multiple times in the background (fastest method for now afaik)
    • use a PS Workflow
    • use Runspaces, but note that due to the way PowerCLI currently works, you can't use multiple threads in the same Runspace


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

6 Replies
LucD
Leadership
Leadership
Jump to solution

There are many ways to speed up a script.

  • use the Get-VIew cmdlet instead of the regular PowerCLI cmdlets.
  • use parallelism
    • with Start-Job you can run a script multiple times in the background (fastest method for now afaik)
    • use a PS Workflow
    • use Runspaces, but note that due to the way PowerCLI currently works, you can't use multiple threads in the same Runspace


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

AmolPatil
Enthusiast
Enthusiast
Jump to solution

Hey Luc,

Yes tried that way too and also tried your other post with job but no luck so far.

I will post my code then check if that is possible in that code.(That also i picked from diffrent sources and customized.)

Share me where to share that ? Emai ?

Regards, Amol Patil VCP 5
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can reach me via the Contact page on my blog.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
AmolPatil
Enthusiast
Enthusiast
Jump to solution

I have sent an email from your site.

Regards, Amol Patil VCP 5
Reply
0 Kudos
AmolPatil
Enthusiast
Enthusiast
Jump to solution

Hey Luc,

Thanks a lot once again..

Finally after yours hints.. I was keep trying to do my VM Inventory using parallel... So finally it is working using Start-Job ☺️

Once again thanks a lot for assisting me or us always..

Regards, Amol Patil VCP 5
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Thanks.
Yes, Start-Job is the simplest and probably most optimal way to run PowerCLI scripts in parallel.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos