{"id":4232,"date":"2013-01-31T00:01:00","date_gmt":"2013-01-31T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/01\/31\/create-a-custom-hyper-v-resource-metering-reset-report\/"},"modified":"2013-01-31T00:01:00","modified_gmt":"2013-01-31T00:01:00","slug":"create-a-custom-hyper-v-resource-metering-reset-report","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/create-a-custom-hyper-v-resource-metering-reset-report\/","title":{"rendered":"Create a Custom Hyper-V Resource Metering Reset Report"},"content":{"rendered":"<p><strong style=\"font-size: 12px\">Summary:<\/strong><span style=\"font-size: 12px\"> Microsoft Scripting Guy, Ed Wilson, shows you how to create a custom Hyper-V Resource Metering reset report by using Windows PowerShell&nbsp;3.0.<\/span><\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Well, I found a pretty cool Pandora app for my <a href=\"http:\/\/www.microsoft.com\/surface\/en-US\/surface-with-windows-rt\/home\" target=\"_blank\">Windows RT Surface<\/a>, and so I am listening to a cool Rolling Stones song as I type this. Actually I am surprised at the quality of the music my little Surface&nbsp;RT is spewing out.<\/p>\n<p style=\"padding-left: 30px\"><a href=\"http:\/\/www.ftc.gov\/opa\/2009\/10\/endortest.shtm\" target=\"_blank\">United States FTC disclaimer:<\/a> The Microsoft Scripting Guys work for the Microsoft Corporation. I have been provided with a Windows Surface&nbsp;RT. In addition, the Microsoft Corporation provides me a salary, health insurance, bonus, U.S. national holidays off, and annual leave. The Microsoft Corporation, however, has not purchased for me the <a href=\"http:\/\/www.microsoft.com\/Surface\/en-US\/accessories\/more-accessories\" target=\"_blank\">Bluetooth wedge mouse<\/a> or <a href=\"http:\/\/www.microsoft.com\/Surface\/en-US\/accessories\/type-cover?v=29145\" target=\"_blank\">type cover<\/a> that I use with my Surface. In addition, the Microsoft Corporation did not buy the Windows Surface&nbsp;RT that the Scripting Wife uses.<\/p>\n<p>Anyway, I am playing around this morning, happy that so far I have no meetings either today or tomorrow. In fact, the week is shaping up tremendously &hellip; and the Scripting Wife and I are planning on heading out on Friday night to see our friends perform at a local club tomorrow evening. We generally do not hang out with people who do not do Windows PowerShell, so this will be sort of a different experience.<\/p>\n<h2>Working with the virtual machine metering report<\/h2>\n<p>The <strong>VMMeteringReportForVirtualMachine<\/strong> object does not display the amount of time that has lapsed since the Resource Metering was last reset.<\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong> &nbsp;&nbsp;See my <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/01\/29\/use-powershell-to-reset-hyper-v-resource-metering.aspx\">Use PowerShell to Reset Hyper-V Resource Metering<\/a> Blog post from Tuesday for more information about resetting the Resource Metering report.<\/p>\n<p>It dawned on me that the <strong>MeteringDuration<\/strong> property contains a <strong>TimeSpan<\/strong> object. I confirmed this by piping to <strong>Get-Member<\/strong> as shown here.<\/p>\n<p style=\"padding-left: 30px\">14:16 C:\\&gt; get-vm * | Measure-VM | gm -Name MeteringDuration<\/p>\n<p style=\"padding-left: 30px\">TypeName: Microsoft.HyperV.PowerShell.VMMeteringReportForVirtualMachine<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType Definition<\/p>\n<p style=\"padding-left: 30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<\/p>\n<p style=\"padding-left: 30px\">MeteringDuration Property&nbsp;&nbsp; System.Nullable[timespan] MeteringDuration {get;}<\/p>\n<p>So, I decided to pipe the <strong>Get-VM<\/strong> command to the <strong>Measure-VM<\/strong> cmdlet and then create a custom object. I named one property <strong>TimeSpan<\/strong>, and I cast the <strong>MeteringDuration<\/strong> property to a [timespan] object. The code is shown here.<\/p>\n<p style=\"padding-left: 30px\">Get-VM -vmname * | Measure-VM |<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; select-Object vmname,<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp; @{LABEL=&#8221;Timespan&#8221;;EXPRESSION={[timespan]$_.MeteringDuration}}<\/p>\n<p>When I run the code, the following output is shown.<\/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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Timespan&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&#8212;&#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;&#8212;&#8212;&#8211;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The big problem with this output is that I have no idea if the <strong>TimeSpan<\/strong> represents 2 days or 2 hours. Well, I guess the 49 would probably be minutes or seconds, and the 1750000 is probably something like ticks, but it would be nice to see the <strong>TimeSpan<\/strong> expanded.<\/p>\n<h2>Creating a new object with TimeSpan details<\/h2>\n<p>So, I decide I want to create a new object that expands the <strong>Days<\/strong>, <strong>Hours<\/strong>, and <strong>Minutes<\/strong> properties from the <strong>TimeSpan<\/strong> object. Because I now have a custom object that contains the <strong>VMName<\/strong> and a <strong>TimeSpan<\/strong> object, it is pretty easy for me to create the desired object. I cannot pipe directly to the <strong>New-Object<\/strong> cmdlet, but I can pipe to the <strong>Foreach-Object<\/strong> cmdlet.<\/p>\n<p>So, I throw the <strong>Foreach-Object<\/strong> cmdlet into the mixture, and in the associated ScriptBlock, I add my <strong>New-Object<\/strong> cmdlet. I can specify properties by using a HashTable notation. So first off, I create a property named <strong>name<\/strong><em>, <\/em>and I assign the value from the <strong>VMName<\/strong> property of my previous object. Now I use the <strong>TimeSpan<\/strong> property from my previous object, and I directly access the <strong>Days<\/strong>, <strong>Hours<\/strong>, and <strong>Minutes<\/strong>. The last step is to choose the type of object&mdash;for this, the <strong>psobject<\/strong> type is fine. Here is the code I created.<\/p>\n<p style=\"padding-left: 30px\">Get-VM -vmname * | Measure-VM |<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; select-Object vmname,<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp; @{LABEL=&#8221;Timespan&#8221;;EXPRESSION={[timespan]$_.MeteringDuration}} |<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; Foreach-Object {<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; New-Object -Property @{<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name=$_.vmname;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Days=$_.TimeSpan.Days;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hours=$_.TimeSpan.hours<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Minutes=$_.timespan.minutes} -type psobject<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p>When I run the above code, the output shown here displays in the output pane on my Windows PowerShell ISE.<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hours&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Days&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Minutes Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp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nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51 c1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>Hmm, the output is what I want, but the order is all messed up. Oh well, I guess I will need to use <strong>Format-Table<\/strong> to fix up the formatting.<\/p>\n<h2>Formatting the output<\/h2>\n<p>The problem with the previous output is that I wanted the <strong>Name<\/strong> of the virtual machine, and then I wanted the <strong>Days<\/strong>, <strong>Hours<\/strong>, and <strong>Minutes<\/strong> to display. I could have just put those properties in order and use the <strong>Format-Table<\/strong>, but because I am playing around, I decided to do something better.<\/p>\n<p>One of the seldom used parameters for the <strong>Format-Table<\/strong> cmdlet is the <strong>GroupBy<\/strong> parameter. Well, did you know I could supply a ScriptBlock for the <strong>GroupBy<\/strong> parameter? If you did know that, have you forgotten it? Well, I decided to add a ScriptBlock for the <strong>GroupBy<\/strong> parameter. So, I group by <strong>Computer Name<\/strong>, but I change the Label to &ldquo;Time Since Last VM Report&rdquo; and then I pick up the name of the virtual machine. Here is the code&mdash;it is cool!<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Format-table -property days, hours, minutes -AutoSize -GroupBy @{<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Label=&#8221;Time since last VM Report&#8221;;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Expression={$_.name} }<\/p>\n<p>&nbsp;The output is shown in the image that follows.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8468.hsg-1-31-13-1.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8468.hsg-1-31-13-1.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>The complete Get-VMResourceReportConvertToObjectFormatTable.ps1 is shown here.<\/p>\n<p style=\"padding-left: 30px\">get-vm -vmname * | Measure-VM |<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; select-Object vmname,<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp; @{LABEL=&#8221;Timespan&#8221;;EXPRESSION={[timespan]$_.MeteringDuration}} |<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; Foreach-Object {<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; New-Object -Property @{<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name=$_.vmname;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Days=$_.TimeSpan.Days;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hours=$_.TimeSpan.hours<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Minutes=$_.timespan.minutes} -type psobject<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } |<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Format-table -property days, hours, minutes -AutoSize -GroupBy @{<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Label=&#8221;Time since last VM Report&#8221;;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Expression={$_.name} }<\/p>\n<p>I uploaded <a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/Create-a-Hyper-V-Resource-a946c8c0\" target=\"_blank\">the complete script to the Scripting Guys Script Repository<\/a>. This should make it easy for you to download and play with the code. Hope you have an awesome day.<\/p>\n<p>Join me tomorrow when I will talk about more cool Windows PowerShell stuff.<\/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, shows you how to create a custom Hyper-V Resource Metering reset report by using Windows PowerShell&nbsp;3.0. Microsoft Scripting Guy, Ed Wilson, is here. Well, I found a pretty cool Pandora app for my Windows RT Surface, and so I am listening to a cool Rolling Stones song as I [&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":[25,271,409,3,4,45],"class_list":["post-4232","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-displaying-output","tag-hyper-v","tag-objects","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, shows you how to create a custom Hyper-V Resource Metering reset report by using Windows PowerShell&nbsp;3.0. Microsoft Scripting Guy, Ed Wilson, is here. Well, I found a pretty cool Pandora app for my Windows RT Surface, and so I am listening to a cool Rolling Stones song as I [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4232","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=4232"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4232\/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=4232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}