VMware Cloud Community
pga07
Contributor
Contributor

Start VM to slow !

Hello,

I have a script to startup all my vm.

$vm = get-vm |where-object{$_.PowerState -eq "PoweredOff"}

$vm |ForEach-Object{

start-vm $_.name

}

This is work fine but it 's to slow for start 200 VM (more 2 hours).

It s possible to launch multiple startup ?

Thanks for your help !

0 Kudos
2 Replies
halr9000
Commander
Commander

Sure, this is easy. Just add a -RunAsync to the end of the Start-VM command. This will queue the requests in a number of seconds and the VC or hostd will take care of the rest.

Also, a tip, well two tips:

1. when embedding code into a forum post, it works best if you use the tags "" at the start and "" at the end (remove the spaces between the tag name and the braces). You put asterisks and such in the code below which may make it look better while posting it but it tends to mix up things and make resulting code invalid.

2. start-vm $_.name is unnecessary. $_ is a VM object, and start-VM knows what to do with them. "start-vm $_" is sufficient.






[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
pga07
Contributor
Contributor

Thank for your answer. i 'll test it the next sunday.

For my next post, i 'll use your comments to post my code.

0 Kudos