PowerCLI: Export VM Memory Limits to csv


image

I wanted to see how the memory limits are configured in my VI3 environment. You can do this via the VIC, but you can also do it via a PowerCLI script and export it to a csv file.

Copy the script and run it. The script will ask you to enter the vCenter server and a path to save the csv file (like c:\temp\memlimits.csv).

$vCenter = Read-Host "Enter vCenter Server"
$csvFile = Read-Host "Enter csv file"

Connect-VIServer $vCenter

Get-VM | sort name | % { $vm = $_ | Get-View ; $vm | select `
    @{ Name = "VM Name"; Expression ={ $vm.Name }},`
    @{ Name = "Memory in MB"; Expression ={ $vm.Config.Hardware.MemoryMB }},`
    @{ Name = "Memory Limits in MB"; Expression ={ $vm.Config.MemoryAllocation.Limit }}`
    } | Export-Csv -NoTypeInformation $csvFile

Invoke-Item $csvFile

Disconnect-VIServer -Confirm:$false

The output will look like this:

image

Advertisements

2 thoughts on “PowerCLI: Export VM Memory Limits to csv

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