Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 231085

Re: Looking for a way to create an automated, and large number of DRS rules.

$
0
0

Try like this, it just needs a change in the Name parameter value and the RegEx pattern for the match operator.

 

$VCenterServer=server

$VMCluster="Production"

 

Connect-ViServer$VCenterServer

# Stick current DRS rules into an array

$DrsRules=Get-DrsRule-Cluster$VMCluster

 

Get-Cluster$VMCluster|Get-VM-Name'*[ab]v'|

Group-Object-Property {$_-match"(?<name>.*)[a|b]v"; $Matches["name"]} |

Where-Object {$_.Count -eq2} |

ForEach-Object {

    if($DrsRules.name -notcontains$_.Values[0][1]){

        New-DrsRule-Cluster$VMCluster-Name$_.Values[0][1]-KeepTogether$false-VM$_.Group

    }

}


Viewing all articles
Browse latest Browse all 231085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>