VMware Cloud Community
andrevechiatto
Enthusiast
Enthusiast

Change DRS Rule name with powercli

I need change names Rules and Groups DRS.

Is there any cmdlet to change the name of an existing rule drs and a DRS group?

1 Reply
ccalvetTCC
Enthusiast
Enthusiast

Regarding the rule it is possible via PowerCLI:

get-cluster 'MyTest' | get-drsrule -name 'OldRuleName' | Set-DrsRule -name 'NewRuleName'

Regarding the DRS group, it doesn't seem possible with PowerCLI directly, however it may be possible via the API accessed through PowerCLI.

I will investigate this.

Edit:

I didn’t find a way to rename the following objects:

VMware.Vim.ClusterHostGroup

VMware.Vim.ClusterVMGroup

Example of a script not working:

$DRSVMGROUP = ((get-cluster 'MyTest').ExtensionData.configurationex.group | where {$_.Name -eq 'OldVirtualMachineDRSGroupName'})

$ClusterConfigSpecEx = New-Object VMware.Vim.ClusterConfigSpecEx

$ClusterGroupSpec = New-Object VMware.Vim.ClusterGroupSpec

$ClusterGroupSpec.operation = 'edit'

$ClusterGroupSpec.Info = $DRSVMGROUP

$ClusterGroupSpec.info.Name = 'NewVMGroupName'

$ClusterConfigSpecEx.groupSpec = $ClusterGroupSpec

$MyCluster = get-cluster 'MyTest' | get-view

$MyCluster.ReconfigureComputeResource_Task($ClusterConfigSpecEx,$true)

So it seems that there are two options:

Not recommended and probably not supported:

Edit the name at the vCenter database itself...but in general it will be strongly recommended to stay as far as possible from the database and use only APIs to work with vCenter.

Start from scratch:

Create new ClusterGroups (Host or VM) with new names.

Import all members from old ClusterGroups to the new ones.

Modify all DRS rules based on ClusterGroups and use the new ClusterGroups instead of the old one.

However all former “ClusterGroup IDs” will be lost. It can generates issues with others applications.

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC