Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save omniproc/a46c7ee73b7850dc46a40575a0606a12 to your computer and use it in GitHub Desktop.
Save omniproc/a46c7ee73b7850dc46a40575a0606a12 to your computer and use it in GitHub Desktop.
$vms = Get-Cluster CLUSTER_NAME_YOU_WANT_TO_NORMALIZE | Get-VM
Write-Host "Old configuration:"
$vms | Get-VMResourceConfiguration
foreach ($vm in $vms)
{
#Normalize CPU shares
# vSphere 5.5 defaults:
# High: 2000 shares per configured vCPU
# Normal: 1000 shares per configured vCPU
# Low: 500 shares per configured vCPU
$cpuShares = ($vm.NumCpu * 1000);
#Normalize Memory shares
# vSphere 5.5 defaults:
# High: 20 shares per megabyte of configured vRAM
# Normal: 10 shares per megabyte of configured vRAM
# Low: 5 shares per megabyte of configured vRAM
$memShares = ($vm.MemoryMB * 10);
$vm | Get-VMResourceConfiguration | Set-VMResourceConfiguration -CpuSharesLevel Custom -NumCpuShares $cpuShares -MemSharesLevel Custom -NumMemShares $memShares
}
Write-Host "New configuration:"
$vms | Get-VMResourceConfiguration
@omniproc
Copy link
Author

omniproc commented Apr 6, 2016

Will normalize any share configuration (CPU / Memory) within a cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment