{"id":4251,"date":"2013-01-27T00:01:00","date_gmt":"2013-01-27T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/01\/27\/weekend-scripter-use-powershell-to-meter-resources-on-hyper-v-windows-server-2012\/"},"modified":"2013-01-27T00:01:00","modified_gmt":"2013-01-27T00:01:00","slug":"weekend-scripter-use-powershell-to-meter-resources-on-hyper-v-windows-server-2012","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-use-powershell-to-meter-resources-on-hyper-v-windows-server-2012\/","title":{"rendered":"Weekend Scripter: Use PowerShell to Meter Resources on Hyper-V Windows Server 2012"},"content":{"rendered":"<p><strong>Summary:<\/strong> Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell&nbsp;3.0 to do Hyper-V Resource Metering on Windows Server&nbsp;2012.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Well, Charlotte looked like someone had taken a huge can of polyurethane and sprayed the entire city&mdash;multiple times. Ok, so it is sort of pretty the way the city glistens in the sun with a thick layer of ice encapsulating the city, but dude, it is dangerous. So, the Scripting Wife and I headed out to the beach. I am sitting in one of those funky coffee houses near the beach, writing my blog posting for today, watching the waves, the surf, and the sand with a nearly unobscured view.<\/p>\n<p>Yes, the Carolina beaches are great in the winter&mdash;when there are very few tourists to clutter things. Some restaurants close for the &ldquo;off season,&rdquo; but Teresa and I have discovered those types of restaurants are not the sort that we like to eat in anyway. We prefer the small, family-owned restaurants that have been in business for 50 years, and because of the quality of their food, and their loyal customer base, they do just fine year round.<\/p>\n<h2>Checking on status of Resource Metering<\/h2>\n<p>Now, it is possible to use performance counters to see how a virtual machine performs. It is also possible to use performance counters to see how the host (the server that hosts the virtual machines) performs. In fact, I wrote an <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/tags\/performance\/\" target=\"_blank\">entire series of articles<\/a> talking about using performance counters with Windows PowerShell (in fact, one of my talks at the <a href=\"http:\/\/powershell.org\/summit\/\" target=\"_blank\">PowerShell Summit<\/a> will be on what I call PoshMon). What was missing was a way to view the resource consumption of the virtual machine related to the host. The <a href=\"http:\/\/blogs.technet.com\/b\/virtualization\/archive\/2012\/08\/16\/introduction-to-resource-metering.aspx\" target=\"_blank\">Introduction to Resource Metering<\/a><em> <\/em>blog post written by Lalithra Fernando on the Virtualization Blog is an excellent place to start. Lalithra also wrote a blog post called <a href=\"http:\/\/blogs.technet.com\/b\/virtualization\/archive\/2012\/08\/20\/how-to-use-resource-metering-with-powershell.aspx?Redirected=true\" target=\"_blank\">How to Use Resource Metering with PowerShell<\/a><em>,&nbsp;<\/em>which is also a good introduction.<\/p>\n<p style=\"padding-left: 30px\"><strong>Exam note<\/strong> &nbsp;&nbsp;One of the objectives on the <a href=\"http:\/\/www.microsoft.com\/learning\/en\/us\/exam.aspx?ID=70-410\" target=\"_blank\">Exam 70-140: Installing and Configuring Windows Server 2012<\/a><em> <\/em>is <em>configure Resource Metering, <\/em>and so if you are working on your new <a href=\"http:\/\/www.microsoft.com\/learning\/en\/us\/mcse-server-infrastructure-certification.aspx\" target=\"_blank\">MCSE for <em>Server Infrastructure<\/em><\/a>, you will want to know this material. Of course, if you are running or thinking about running Hyper-V on Windows Server&nbsp;2012, you will want to know this information as well.<em> <\/em>Like I said yesterday, I like the MCSE exams because they help me to come up to speed quickly on a new product by forcing me to learn about the new features.<\/p>\n<p>So, the first thing I need to do is to check on the status of Resource Metering on my Hyper-V server. To do this, I use the <strong>Get-VM<\/strong> cmdlet from the Hyper-V module to return virtual machine objects, and I pipe these to the <strong>Select-Object<\/strong> cmdlet, and I choose the <strong>name<\/strong> and the <strong>ResourceMeteringEnabled<\/strong><em> <\/em>properties. This command is shown here along with the associated output from the command.<\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong> &nbsp;&nbsp;Keep in mind that the <strong>Get-VM<\/strong> and other cmdlets from the Hyper-V require admin rights to run, and therefore, if you are doing this on Windows&nbsp;8, you will need to start Windows PowerShell with admin rights.<\/p>\n<p style=\"padding-left: 30px\">14:34 C:\\&gt; get-vm | select name, resourcemeteringenabled<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ResourceMeteringEnabled<\/p>\n<p style=\"padding-left: 30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p style=\"padding-left: 30px\">c1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; False<\/p>\n<p style=\"padding-left: 30px\">C2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;False<\/p>\n<p style=\"padding-left: 30px\">DC1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; False<\/p>\n<p style=\"padding-left: 30px\">sql1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; False<\/p>\n<h2>Enabling Resource Metering<\/h2>\n<p>Well, the next thing I need to do is to enable Resource Metering. To do this, I use the <strong>Enable-VMResourceMetering<\/strong> cmdlet. I can enable Resource Metering for a specific machine, such as for SQL1, by specifying the <strong>&ndash;VMName<\/strong> parameter. The command to do this is shown here (keep in mind that nothing returns from this command).<\/p>\n<p style=\"padding-left: 30px\">Enable-VMResourceMetering -VMName sql1<\/p>\n<p style=\"padding-left: 30px\"><strong>Exam ALERT<\/strong>&nbsp; &nbsp;The default parameter set for the <strong>Enable-VMResourceMetering<\/strong> is <strong>VMName<\/strong>, and therefore, you can simply supply the name of the virtual machine <strong>Enable-VMResourceMetering<\/strong> SQL1. But, there are three parameter sets: <strong>VMName<\/strong>, <strong>VM<\/strong>, and <strong>ResourcePoolName<\/strong>. To make matters worse, <strong>ResourcePoolName<\/strong> has an alias of <strong>Name<\/strong>. Keep in mind, <strong>VMName<\/strong> is the name of the virtual machine, <strong>VM<\/strong> is a virtual machine object (such as returned by <strong>Get-VM<\/strong>) and <strong>ResourcePoolName<\/strong> and <strong>Name<\/strong> are the names of virtual machine resource pools. There is no alias for <strong>VMName<\/strong> or <strong>VM<\/strong>. The following illustrates available parameter aliases.<\/p>\n<p style=\"padding-left: 30px\">15:31 C:\\&gt; gcm Enable-VMResourceMetering | select -expand parameters | % {$_.values} |<\/p>\n<p style=\"padding-left: 30px\">? aliases | select name, aliases<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Aliases<\/p>\n<p style=\"padding-left: 30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p style=\"padding-left: 30px\">ResourcePoolName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Name}<\/p>\n<p style=\"padding-left: 30px\">Verbose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {vb}<\/p>\n<p style=\"padding-left: 30px\">Debug&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {db}<\/p>\n<p style=\"padding-left: 30px\">ErrorAction&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ea}<\/p>\n<p style=\"padding-left: 30px\">WarningAction&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {wa}<\/p>\n<p style=\"padding-left: 30px\">ErrorVariable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {ev}<\/p>\n<p style=\"padding-left: 30px\">WarningVariable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {wv}<\/p>\n<p style=\"padding-left: 30px\">OutVariable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {ov}<\/p>\n<p style=\"padding-left: 30px\">OutBuffer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{ob}<\/p>\n<p>&nbsp;<\/p>\n<p>If I want to, I can enable Resource Metering on all of the virtual machines by piping the results from <strong>Get-VM<\/strong> to the <strong>Enable-VMResourceMetering<\/strong> cmdlet, as shown here.<\/p>\n<p style=\"padding-left: 30px\">get-vm | Enable-VMResourceMetering<\/p>\n<h2>Getting the Resource Metering report<\/h2>\n<p>To get the report of metered resources, use the <strong>Measure-VM<\/strong> cmdlet. The default parameter set is <strong>VMName<\/strong>, and therefore, the parameter can be left out. The <strong>VMName<\/strong> parameter accepts an array, and therefore, I can obtain information from more than one virtual machine at a given time.<\/p>\n<p>The following illustrates obtaining Resource Metering reports from one and from two virtual machines. The syntax is shown here.<\/p>\n<p style=\"padding-left: 30px\">Measure-VM dc1<\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong>&nbsp; &nbsp;When a virtual machine is offline, it reports 0.<\/p>\n<p>The following image illustrates using this command, as well as the command to measure two virtual machines.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3666.HSG-1-27-13-01.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3666.HSG-1-27-13-01.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<h2>Getting a metering report for all virtual machines<\/h2>\n<p>I can use the <strong>Get-VM<\/strong> cmdlet and pipe the returned <strong>VirtualMachine<\/strong> objects to the <strong>Measure-VM<\/strong> cmdlet to obtain a report on all of my virtual machines. The command is shown here.<\/p>\n<p style=\"padding-left: 30px\">get-vm | Measure-VM<\/p>\n<p>The command and its output associated used to measure all virtual machines are shown in the image that follows.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6215.HSG-1-27-13-02.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6215.HSG-1-27-13-02.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>But realize this IS Windows PowerShell, and therefore, everything is an object. This means I am not limited to the output appearing above. I use the <strong>Get-Member<\/strong> cmdlet (<strong>gm<\/strong> is an alias) to see what my options are. The command and its output are shown here.<\/p>\n<p style=\"padding-left: 30px\">16:02 C:\\&gt; get-vm | Measure-VM | gm -MemberType *property&nbsp;<\/p>\n<p style=\"padding-left: 30px\">TypeName: Microsoft.HyperV.PowerShell.VMMeteringReportForVirtualMachine&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType&nbsp;&nbsp;&nbsp; Definition<\/p>\n<p style=\"padding-left: 30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<\/p>\n<p style=\"padding-left: 30px\">AvgCPU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty AvgCPU = AverageProcessorUsage<\/p>\n<p style=\"padding-left: 30px\">AvgRAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty AvgRAM = AverageMemoryUsage<\/p>\n<p style=\"padding-left: 30px\">MaxRAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty MaxRAM = MaximumMemoryUsage<\/p>\n<p style=\"padding-left: 30px\">MinRAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty MinRAM = MinimumMemoryUsage<\/p>\n<p style=\"padding-left: 30px\">TotalDisk&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty TotalDisk = TotalDiskAllocation<\/p>\n<p style=\"padding-left: 30px\">AverageMemoryUsage&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Nullable[int] AverageMemoryUsage&#8230;<\/p>\n<p style=\"padding-left: 30px\">AverageProcessorUsage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Nullable[int] AverageProcessorUs&#8230;<\/p>\n<p style=\"padding-left: 30px\">ComputerName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ComputerName {get;}<\/p>\n<p style=\"padding-left: 30px\">MaximumMemoryUsage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Nullable[int] MaximumMemoryUsage&#8230;<\/p>\n<p style=\"padding-left: 30px\">MeteringDuration&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Nullable[timespan] MeteringDurat&#8230;<\/p>\n<p style=\"padding-left: 30px\">MinimumMemoryUsage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Nullable[int] MinimumMemoryUsage&#8230;<\/p>\n<p style=\"padding-left: 30px\">NetworkMeteredTrafficReport Property&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Microsoft.HyperV.PowerShell.VMPortAclMe&#8230;<\/p>\n<p style=\"padding-left: 30px\">TotalDiskAllocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Nullable[int] TotalDiskAllocatio&#8230;<\/p>\n<p style=\"padding-left: 30px\">VMId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; guid VMId {get;}<\/p>\n<p style=\"padding-left: 30px\">VMName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string VMName {get;}<\/p>\n<h2>Sorting the output<\/h2>\n<p>I am not too impressed with the random order of the output. What I am concerned with is the amount of CPU utilization. So, I sort the output by AvgCPU (I know I can do this because of the output from the <strong>Get-Member<\/strong> cmdlet). Here is the command I use to sort the output by average CPU usage.<\/p>\n<p style=\"padding-left: 30px\">get-vm | Measure-VM | sort avgCPU -Descending<\/p>\n<p>The command and its associated output are shown here.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5518.HSG-1-27-13-03.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5518.HSG-1-27-13-03.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>Well, that is about it for now. I want to head down to the beach and take a few pictures before it gets too late. <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/01\/28\/use-powershell-to-configure-hyper-v-resource-metering.aspx\" target=\"_blank\">Join me tomorrow<\/a> when I will continue this discussion about Hyper-V on Windows Server&nbsp;2012.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell&nbsp;3.0 to do Hyper-V Resource Metering on Windows Server&nbsp;2012. Microsoft Scripting Guy, Ed Wilson, is here. Well, Charlotte looked like someone had taken a huge can of polyurethane and sprayed the entire city&mdash;multiple times. Ok, so it is sort of pretty the way the city [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[271,362,3,61,45,368],"class_list":["post-4251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-hyper-v","tag-powershell-3","tag-scripting-guy","tag-weekend-scripter","tag-windows-powershell","tag-windows-server-2012"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell&nbsp;3.0 to do Hyper-V Resource Metering on Windows Server&nbsp;2012. Microsoft Scripting Guy, Ed Wilson, is here. Well, Charlotte looked like someone had taken a huge can of polyurethane and sprayed the entire city&mdash;multiple times. Ok, so it is sort of pretty the way the city [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=4251"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4251\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=4251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}