VMware Cloud Community
matthewcdove
Contributor
Contributor
Jump to solution

Powershell script to get Allocated and Used Memory

I'm trying to run a powershell script against a VC.  The goal of the script is to get a table that shows the name, powerstate, allocated RAM, used RAM, VC, and VCL for each VM.  What is the command to get the used ram?

So, I started with:

Connect-VIServer -Server -User username -Password password

Get-VM | select Name, Description, PowerState,  MemoryGB, | Export-csv –path “C:\VMInventory\Memory.csv” –NoTypeInformation

0 Kudos
1 Solution

Accepted Solutions
sneddo
Hot Shot
Hot Shot
Jump to solution

Try this:

Get-VM | select Name, Description, PowerState,  MemoryGB, @{n="HostMemoryUsage";e={$_.ExtensionData.Summary.QuickStats.HostMemoryUsage}}

That  should return the same value as the "Consumed Host Memory" displayed in the vSphere client (in MB).

View solution in original post

0 Kudos
1 Reply
sneddo
Hot Shot
Hot Shot
Jump to solution

Try this:

Get-VM | select Name, Description, PowerState,  MemoryGB, @{n="HostMemoryUsage";e={$_.ExtensionData.Summary.QuickStats.HostMemoryUsage}}

That  should return the same value as the "Consumed Host Memory" displayed in the vSphere client (in MB).

0 Kudos