Moving on in my “scripting dynamic memory” series, the next thing to look at is how to get the current memory usage and memory available data that we display in the Hyper-V manager. You can get the current memory usage by just looking at MSVM_Memory (http://msdn.microsoft.com/en-us/library/cc136855(v=VS.85).aspx), but unfortunately you cannot get the memory availability that way. To get the memory availability you need to use GetSummaryInformation (http://msdn.microsoft.com/en-us/library/cc160706(v=VS.85).aspx).
GetSummaryInformation is an API that we use as a light weight way to get a bunch of information about a virtual machine. It returns a Msvm_SummaryInformation Class (or a collection of these) (http://msdn.microsoft.com/en-us/library/cc136898(v=VS.85).aspx)
Some things to know:
- While the code above gets the summary information for a single virtual machine – GetSummaryInformation allows you to pass in a null value for the system setting data. In this case you will get information about all virtual machines on the system.
- While I am only displaying information about the current memory and the memory availability – you can get a lot more information in this way. Hit the link for GetSummaryInformation above if you want to see all that you can possibly get in this fashion.