Reputation: 1188
I want to get memory of a virtual machine with Hyper-V WMI Classes. There are 4 memory classes; but I could not find any properties of them to get memory value.
Msvm_Memory class have BlockSize and NumberOfBlocks properties. When I multiply them, I could not get correct memory.
Respect to https://msdn.microsoft.com/en-us/library/hh850175(v=vs.85).aspx It is already wrong approach.
BlockSize Data type: uint64 Access type: Read-only The size, in bytes, of the blocks that form the storage extent. If variable block size, then the maximum block size, in bytes, should be specified. If the block size is unknown, or if a block concept is not valid (for example, for aggregate extents, memory, or logical disks), enter a 1 (one). This property is inherited from CIM_StorageExtent, and it is always set to 1048576.
Which class and property should I use?
Upvotes: 2
Views: 723
Reputation: 2710
You can use the Msvm_MemorySettingData
class to access the defined memory properties of an instance. You may filter the results by InstanceID
and parse AllocationUnits
together with Limit
to get the configured maximum memory amount.
In the following case there is 1 TB of memory that can be allocated for the specific instance "4764334E-E001-4176-82EE-5594EC9B530E
".
Example InstanceID: "Microsoft:Definition\\4764334E-E001-4176-82EE-5594EC9B530E\\Default"
AllocationUnits: "bytes * 2^20"
Limit: 1048576
Msvm_MemorySettingData: https://msdn.microsoft.com/en-us/library/hh850176(v=vs.85).aspx
Upvotes: 2