CodingVMware

Export and Import VMware affinity rules

More searching for migration of my VCenter and I found http://ict-freak.nl/2009/09/06/powercli-export-and-import-drs-rules-v2/ which allows me to export and import the affinity rules

Export

Get-Cluster -Name "TUK_UT_04" | Get-DrsRule | `
Export-CliXml 'd:tempAffinityRules.xml'

Import

ForEach ($rule in (Import-CliXml 'd:tempAffinityRules.xml')){
    New-DrsRule -Cluster (Get-Cluster -Name "TUK_UT_04") `
    -Name $rule.Name -Enabled $rule.Enabled `
    -KeepTogether $rule.KeepTogether `
    -VM (Get-VM -Id $rule.VmIds)}

Leave a Reply