VMware Cloud Community
Kevin_Smith
Contributor
Contributor
Jump to solution

How do you retrieve an ESX Hosts memory available for VM's from Powershell?

I can get the hosts total physical memory, and service console memory, but cannot seem to find the memory used by the system, ideally I want to retreive the figures shown in virtual centre

Reply
0 Kudos
1 Solution

Accepted Solutions
cody_bunch
Hot Shot
Hot Shot
Jump to solution

get-vmhost | get-view | %{ $_.SystemResources.config.MemoryAllocation }

No?

-Cody Bunch

-Cody Bunch http://professionalvmware.com

View solution in original post

Reply
0 Kudos
7 Replies
cody_bunch
Hot Shot
Hot Shot
Jump to solution

get-vmhost | get-view | %{ $_.SystemResources.config.MemoryAllocation }

No?

-Cody Bunch

-Cody Bunch http://professionalvmware.com
Reply
0 Kudos
cody_bunch
Hot Shot
Hot Shot
Jump to solution

Better yet:

PS > get-vmhost | get-view | %{ $_.Summary.QuickStats } | fl *

OverallCpuUsage : 874

OverallMemoryUsage : 3162

DistributedCpuFairness : 0

DistributedMemoryFairness : 0

DynamicType :

DynamicProperty :

-Cody Bunch

-Cody Bunch http://professionalvmware.com
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

What you get with QuickStats is "Physical memory usage on the host in MB."

I think he wants what the VI Client shows as System and Virtual Machines memory.


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

Reply
0 Kudos
cody_bunch
Hot Shot
Hot Shot
Jump to solution

My numbers match up with what is shown on the summary page for my host using the VI Client... Am I missing something?

-Cody Bunch http://professionalvmware.com
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sorry, I only looked at your QuickStats statement.

The one with SystemResources matches the value in the VI client.


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

Reply
0 Kudos
Mllii
Enthusiast
Enthusiast
Jump to solution

When connecting this to a VC how do i get it to display the ESX host for each one?

and also how do i get it in to a table format

Reservation : 45379

ExpandableReservation : False

Limit : 45379

Shares : VMware.Vim.SharesInfo

OverheadLimit : 0

DynamicType :

DynamicProperty :

to something like

Host Reservation ExpandableReservation Limit Shares

ESX01 45379 False 45379 VMware.Vim.SharesInfo

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Something like this:

$report = @()
Get-VMHost | Sort-Object -property Name | %{
  $_ | Get-View | %{
    $row = "" | select Host, Reservation, ExpandableReservation,Limit,Shares
	$row.Host = $_.Name
	$row.Reservation = $_.SystemResources.config.MemoryAllocation.Reservation
	$row.ExpandableReservation = $_.SystemResources.config.MemoryAllocation.ExpandableReservation
	$row.Limit = $_.SystemResources.config.MemoryAllocation.Limit
	$row.Shares = $_.SystemResources.config.MemoryAllocation.Shares.Shares
 	$report += $row}}
$report | ft

For the Shares property I used the actual Shares value instead of the name of the object.


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

Reply
0 Kudos