I currently have DPM running on my cluster. I have a script that will automatically create VM's and deploy them for me. However, sometimes the placement of the VM is on a host that is in standby and the script fails. How can I make sure that the script only chooses a host that is powered on? I have the -DrsAutomationLevel set to "FullyAutomated" in my script. The code I am using below is what creates the VM.
$vm= New-VM -Name $Server_Name -NumCPU 1 -DiskMB 40960 -DrsAutomationLevel FullyAutomated -MemoryMB 2048 -GuestID "winNetEnterpriseGuest" -CD:$true -Datastore $datastore -VMHost $vmhost
I am not sure what the issue is.
Hello, drwoodberry-
You can handle this by first getting a host that is in a Connected state, then use that host for the -VMHost parameter to New-VM. So, like:
## get a VMHost that is connected
$hostToUse = Get-Cluster myCluster | Get-VMHost | ?{$_.ConnectionState -eq "Connected"} | Get-Random
New-VM -Name ..<snip>.. -VMHost $hostToUse
Enjoy.
Hello, drwoodberry-
You can handle this by first getting a host that is in a Connected state, then use that host for the -VMHost parameter to New-VM. So, like:
## get a VMHost that is connected
$hostToUse = Get-Cluster myCluster | Get-VMHost | ?{$_.ConnectionState -eq "Connected"} | Get-Random
New-VM -Name ..<snip>.. -VMHost $hostToUse
Enjoy.
Thanks so much with your help on this!