VMware Cloud Community
td_sk
Contributor
Contributor
Jump to solution

Need to now the resources capacity using a template VM

HI All,

Thanks in advance,

I am looking for a Powercli script which need  give a output showing  how many such  VMs can be deployed in ESXi cluster if the sample VM configuration provided.@

Sample VM

Memory 4 GB

CPU 2

siv

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this.

Note that this is not a real slots calculation for a cluster, that would require looking at the actual usage of the largest VM.

Also note that the script uses the available threads, if cores are needed the property for the CPU needs to be adapted.

$vMem = 4

$vCpu = 2

$clusterName = 'MyCluster'

$esx = Get-Cluster -Name $clusterName | Get-VMHost

$tvCpu = $esx | Select @{N='vCPU';E={$_.ExtensionData.Hardware.CpuInfo.NumCpuThreads}} |

Measure-Object -Property vCPU -Sum | Select -ExpandProperty Sum

$tvMem = $esx | Measure-Object -Property MemoryTotalGB -Sum | Select -ExpandProperty Sum

Select -InputObject $clusterName -Property @{N='Cluster';E={$_}},

            @{N='CPU Slots';E={[math]::Floor($tvCpu/$vCpu)}},

            @{N='Mem Slots';E={[math]::Floor($tvMem/$vMem)}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

You could do something like this.

Note that this is not a real slots calculation for a cluster, that would require looking at the actual usage of the largest VM.

Also note that the script uses the available threads, if cores are needed the property for the CPU needs to be adapted.

$vMem = 4

$vCpu = 2

$clusterName = 'MyCluster'

$esx = Get-Cluster -Name $clusterName | Get-VMHost

$tvCpu = $esx | Select @{N='vCPU';E={$_.ExtensionData.Hardware.CpuInfo.NumCpuThreads}} |

Measure-Object -Property vCPU -Sum | Select -ExpandProperty Sum

$tvMem = $esx | Measure-Object -Property MemoryTotalGB -Sum | Select -ExpandProperty Sum

Select -InputObject $clusterName -Property @{N='Cluster';E={$_}},

            @{N='CPU Slots';E={[math]::Floor($tvCpu/$vCpu)}},

            @{N='Mem Slots';E={[math]::Floor($tvMem/$vMem)}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos