VMware Cloud Community
bvi1006
Enthusiast
Enthusiast
Jump to solution

Start all vms in and exclude a folder

Hi,

I would like to start up all of our vms with the exception of those residing in a particular folder. In addition, I would like to stagger the power ups so as not to overwhelm the environment. Has anyone already written a script for one or both of these and is willing to share?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could use the following trick

$excludedVM = Get-Folder -Name MyFolder | Get-VM | Select -ExpandProperty Name

Get-VM | Where {$excludedVM -notcontains $_.Name} | Start-VM

If you want to stagger the powerons of the VMs, you could use a Start-Sleep cmdlet

$excludedVM = Get-Folder -Name MyFolder | Get-VM | Select -ExpandProperty Name

Get-VM | Where {$excludedVM -notcontains $_.Name} | %{

   Start-Sleep -Seconds 5

   Start-VM -VM $_

}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You could use the following trick

$excludedVM = Get-Folder -Name MyFolder | Get-VM | Select -ExpandProperty Name

Get-VM | Where {$excludedVM -notcontains $_.Name} | Start-VM

If you want to stagger the powerons of the VMs, you could use a Start-Sleep cmdlet

$excludedVM = Get-Folder -Name MyFolder | Get-VM | Select -ExpandProperty Name

Get-VM | Where {$excludedVM -notcontains $_.Name} | %{

   Start-Sleep -Seconds 5

   Start-VM -VM $_

}


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

0 Kudos
bvi1006
Enthusiast
Enthusiast
Jump to solution

Thanks Luc!

Smiley Happy

0 Kudos