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!
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
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
Thanks Luc!