Hi,
Currently running a script which is powering on VM's within a given Resource Pool, the issue im having is when it loops round it is picking the same VM up again and hence getting the error 'cannot be performed in the current state Powered on)
If I strip out the commands and run them from the VI Toolkit I get the same results, i have highlighted the line i think is causing me the issue.
add-pssnapin vmware.vimautomation.core
connect-viserver = "xxxx"
$pools = Get-ResourcePool -Server $serv | where-object { ($_.Name -ne "Test1") -and ($_.Name -ne "Resources") -and ($_.Name -ne "Test2") }
foreach ($pool in $pools ) {
$vms = Get-VM -Location $pool | where-object {$_.PowerState -eq "PoweredOff"}
foreach ($vm in $vms) {
if ( $vm -ne $null ) {
start-vm -VM $vms
}
}
}
Cheers in advance..