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
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).
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).