PowerCLI: Retrieve VMs where CPU or Memory Reservation has been enabled

The below script block will retrieve VMs where either or both CPU and Memory reservation has been configured and return the value by using the Get-VM cmdlet and retriving the value of both the ‘ExtensionData.ResourceConfig.CpuAllocation.Reservation’ and ‘ExtensionData.ResourceConfig.MemoryAllocation.Reservation’ properties.

 

$VMs = Get-VM | Where-Object {$_.ExtensionData.ResourceConfig.MemoryAllocation.Reservation -ne "0" -or $_.ExtensionData.ResourceConfig.CpuAllocation.Reservation -ne "0"}
ForEach ($VM in $VMs)
    { 
    "" | Select @{N="Name";E={$VM.Name}},
    @{N="CPU Reservation";E={$VM.ExtensionData.ResourceConfig.CpuAllocation.Reservation}},
    @{N="Memory Reservation";E={$VM.ExtensionData.ResourceConfig.MemoryAllocation.Reservation }} 
    } 
Advertisements

3 thoughts on “PowerCLI: Retrieve VMs where CPU or Memory Reservation has been enabled

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s