PowerShell one-liner for inventory of memory configurations and availability–Part one

A customer of mine is planning to consolidate several Hyper-V clusters into one or two big ones.
In order to do that, I had to report on the amounts of memory currently offered by the Hyper-V hosts and the memory configurations of the virtual machines.

When I would use MAP, yet another tool would be introduced into the environment… and only to report on the memory configuration? It seemed to me that this would be a bit overkill.
But then there is SCOM. This customer already has SCOM implemented and configured… but since I’m a n00b when it comes to SCOM this would not have been my favorite solution for such a simple task.

So I turned yet again to my buddy PowerShell Glimlach

I created a small one-liner to provide an output of all the VM’s, their respective nodes, the amount of memory offered by the nodes and the memory configuration of the VM’s.

Note: This one-liner looks at static memory configurations, not dynamic memory configurations and is based on the SCVMM PowerShell cmdlets

Get-VM -vmmserver SCVMM01 | select name,memory,vmhost,@{n=’TotalMemoryOfHost(GB)’;e={"{0:N0}" -f ((Get-VMHost &_.VMHost).TotalMemory/1MB)}} | sort VMHost | convertto-html > D:\Temp\MemoryConfig.html

This will give you an output looking like this:


Leave a Reply

Your email address will not be published. Required fields are marked *