Goal – For a set of Storage Clusters (you provide via a text file); you want to these three settings changed.
- Default VM affinity = un-checked aka Do not keep VMDKs together by default
- I/O metric inclusion = un-checked aka I/O metrics for Storage DRS recommendations are disabled
- Space threshold = 75% aka utilized space per datastore
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # Found 6/19/16 http://vmscribble.com/powercli/change-sdrs-vm-affinity-io-metric-space-threshold-by-cluster-script # Add the PowerCLI snapin to PowerShell Add-PSsnapin VMware.VimAutomation.Core-ErrorAction SilentlyContinue # thanks http://frankdenneman.nl/2012/02/21/impact-of-intra-vm-affinity-rules-on-storage-drs/ functionSet-DatastoreClusterDefaultIntraVmAffinity{ param( [CmdletBinding()] [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] [PSObject]$DSC, [Switch]$Enabled ) process{ $SRMan=Get-View StorageResourceManager if($DSC.GetType().Name-eq"string"){ $DSC=Get-DatastoreCluster-Name$DSC|Get-View } elseif($DSC.GetType().Name-eq"DatastoreClusterImpl"){ $DSC=Get-DatastoreCluster-Name$DSC.Name|Get-View } $spec=New-ObjectVMware.Vim.StorageDrsConfigSpec $spec.podConfigSpec=New-ObjectVMware.Vim.StorageDrsPodConfigSpec $spec.podConfigSpec.DefaultIntraVmAffinity=$Enabled $SRMan.ConfigureStorageDrsForPod($DSC.MoRef,$spec,$true) } } # Set Variables $vCenter=Read-Host"Enter the FQDN of the vCenter" $listofclusters=Read-Host"Enter the path to the list of storage clusters ex. c:scriptsclusters.txt" $clusName=Get-Content-path$listofclusters # Connect to your vCenter Connect-VIServer$vCenter # Default VM affinity = un-checked Get-DatastoreCluster$clusName|Set-DatastoreClusterDefaultIntraVmAffinity # I/O metric inclusion = un-checked / Space threshold = 75% Get-DatastoreCluster$clusName|Set-DatastoreCluster-IOLoadBalanceEnabled$false|Set-DatastoreCluster-SpaceUtilization75-Confirm:$false # Disconnect from the vCenter Disconnect-VIServer$vCenter-Confirm:$false |