VMware Cloud Community
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

Sum all Ram usage of vm´s from .txt file

I need a script to sum up all ram usage of all vm´s in a .txt file.

How can I do that?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do like this

$vmNames = Get-Content -Path .\vmnames.txt

(Get-VM -Name $vmNames).ExtensionData.Summary.QuickStats.GuestMemoryUsage | Measure-Object -Sum

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

Is that assigned memory or actually used memory, or both?

There are quite a few values for that.

This just shows some of them

$vmNames = Get-Content -Path .\vmnames.txt

Get-VM -Name $vmNames |

Select Name,MemoryGB,

   @{N='MaxMemoryGB';E={$_.ExtensionData.Summary.RunTime.MAxMemoryUsage}},

   @{N='GuestOSMemoryGB';E={$_.ExtensionData.Summary.QuickStats.GuestMemoryUsage}}


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Judging from your other thread, you seem to want to summarise the memory over all VMs.

$vmNames = Get-Content -Path .\vmnames.txt

Get-VM -Name $vmNames | Measure-Object -Property MemoryGB -Sum


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

0 Kudos
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

It is actual usage.

And I need to end up with one number of the total usage of ram for all vm´s (sum).

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could do like this

$vmNames = Get-Content -Path .\vmnames.txt

(Get-VM -Name $vmNames).ExtensionData.Summary.QuickStats.GuestMemoryUsage | Measure-Object -Sum

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

0 Kudos
vmwarelicense12
Enthusiast
Enthusiast
Jump to solution

Just what I was looking for. Thanks.

0 Kudos