Trying to delete just one VM to host affinity rule in all clusters in all datacenters in one vCenter.
Here is what i have so far but its not working
ForEach($dc in Get-Datacenter){$dc | Get-Cluster) If (DrsRule -Name eq "Rule 1 VMs to Host") Then DrsRule.Enabled = False Else Do Nothing}
You can't change a property like that on an object.
Again have a look at the DRSRule module as I mentioned in Re: PowerCLI script to disable vm affinity rules
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
As from the PowerCLI 6.5.2 release there are now built in cmdlets for that functionality.
See New Release: PowerCLI 6.5.1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference