AutomationStat1
Contributor
Contributor

Script to Edit Cluster DRS Rules

I am working on a script to create a Cluster, add HA/DRS, Create DRS groups and place VMs in those groups based on their names. So far I have:

$cluster = Read-Host "Enter the Cluster Name"

Get-Cluster | where Name -eq $cluster | Set-Cluster -HAEnabled:$true -DrsEnabled:$true

$VMs = Get-Cluster -name $cluster | Get-VM | foreach { $_.Name }

Get-Cluster -name $cluster | New-DrsVMGroup -name 'Group1' | Set-DRSVMGroup -VM $VMs | where name -like prod

Get-Cluster -name $cluster | New-DrsVMGroup -name 'Group2' | Set-DRSVMGroup -VM $VMs | where name -like dev

Thoughts?

0 Kudos
1 Reply
LucD
Leadership
Leadership

I suggest you place the Where-clauses after the Get-VM cmdlets, and not after the Set-DRSVMGroup cmdlet.

That will not work as I suspect you intended it.


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

0 Kudos