VMware Cloud Community
vmhyperv
Contributor
Contributor
Jump to solution

Sum of VMs vRAM on a Host

Hi Everyone,

        I wanted to find out the  vRAM assigned for the sum of all the vms on the host through powercli script and output in csv format.Any help on this will much appreciated.

thanks

vmguy

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Take a look at Luc's Query vRAM blogpost. I hope it does all that you need.

To write the output to a .csv file you can pipe the result of Luc's Get-vRAMInfo function to the Export-Csv cmdlet.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
5 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Take a look at Luc's Query vRAM blogpost. I hope it does all that you need.

To write the output to a .csv file you can pipe the result of Luc's Get-vRAMInfo function to the Export-Csv cmdlet.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
vmhyperv
Contributor
Contributor
Jump to solution

Hi Rob,

    Will this Script give total Assigned Memory for all the VMs on the Host ?Waiting for your reply

Thanks

vmguy

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The script gives the configured, used and entitled vRAM per license type per vCenter server. Not exactly the same as per host.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
RvdNieuwendijk
Leadership
Leadership
Jump to solution

I made a new script exactly what you asked for:

Get-VMHost |
Sort-Object -Property Name |
ForEach-Object {
  if ($_)
  {
    $VMHost = $_
    $vRamAssigned = 0
    $VMHost |
    Get-VM |
    Where-Object {$_.PowerState -eq "PoweredOn"} |
    ForEach-Object {
      if ($_) {
        $VM = $_
        $vRamAssigned += if ($VM.MemoryMB -gt 96GB/1MB)
          {96GB}
          else
          {$VM.MemoryMB}        
      }
    }
    New-Object -TypeName PSObject -Property @{
      VMHost = $VMHost.Name
      vRamAssignedGB = [Math]::Round($vRamAssigned/1KB,2)
    }
  }
} |
Select-Object -Property VMHost,vRamAssignedGB |
Export-Csv -Path vRamInfo.csv -NoTypeInformation -UseCulture

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
vmhyperv
Contributor
Contributor
Jump to solution

Thanks for your prompt reponse.I will get back to you after testing.

thanks

vmguy

0 Kudos