Thursday, September 23, 2010

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:\temp\AffinityRules.xml' 

Import

ForEach ($rule in (Import-CliXml 'd:\temp\AffinityRules.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)} 

No comments: