{"id":9531,"date":"2012-05-04T00:01:00","date_gmt":"2012-05-04T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/05\/04\/using-performance-counters-with-the-out-gridview-cmdlet\/"},"modified":"2012-05-04T00:01:00","modified_gmt":"2012-05-04T00:01:00","slug":"using-performance-counters-with-the-out-gridview-cmdlet","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/using-performance-counters-with-the-out-gridview-cmdlet\/","title":{"rendered":"Using Performance Counters with the Out-GridView Cmdlet"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson demonstrates how to use the <b>Out-GridView<\/b> cmdlet with performance counter information.<\/p>\n<p><img decoding=\"async\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" \/>&nbsp;Hey, Scripting Guy! I have a question, and hopefully you will not think it is a stupid one. During the 2012 Scripting Games, one of the events had to do with using performance counters. I thought that was a pretty good idea, so I started playing around with them. Then I saw your blogs about using the <b>Out-GridView<\/b> cmdlet, and I thought it would make sense to combine the two: performance counters and the <b>Out-GridView<\/b> cmdlet. The problem is that it seems to not work. So is this a known bug, or was it never intended to work together at all?<\/p>\n<p>&mdash;CT<\/p>\n<p><img decoding=\"async\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" \/>&nbsp;Hello CT,<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today is an awesome day. I had a great meeting with the TechEd Connect Zone people about the Scripting Guys booth at <a href=\"http:\/\/northamerica.msteched.com\/?mtag=scriptingguys#fbid=XfmOFYQH7yt\" target=\"_blank\">Microsoft TechEd 2012<\/a>. TechEd 2012 will be in Orlando, Florida in the United States, and it will run June 11&ndash;14. I grew up in Florida, and I am excited to have the chance to go &ldquo;home&rdquo; again. In fact, the Scripting Wife and I are going to maximize our time in the sunshine state. I am speaking at <a href=\"http:\/\/www.sqlsaturday.com\/132\/eventhome.aspx\" target=\"_blank\">SQL Saturday in Pensacola, Florida<\/a> on June 9 on the way to Orlando. On the way home, we are stopping in Jacksonville, Florida on June 16 where I will be speaking at the <a href=\"http:\/\/itprocamp.com\/jacksonville\/\" target=\"_blank\">Jacksonville IT Pro Camp<\/a>. &nbsp;<\/p>\n<h2>The problem of Out-GridView and performance info<\/h2>\n<p>CT, using the <b>Out-GridView<\/b> cmdlet to view performance information in an easy-to-manipulate grid control is not a bad idea, and certainly, it works. The problem is that you need to understand a bit more about the underlying performance objects that are returned by the <b>Get-Counter<\/b> cmdlet.<\/p>\n<p><b>Note<\/b>&nbsp;&nbsp;&nbsp;I have written a number of blogs about using Windows PowerShell and performance counters. Please refer to <a href=\"http:\/\/blogs.technet.com\/search\/searchresults.aspx?q=get-counter&amp;sections=7618\" target=\"_blank\">this list of blog posts<\/a> for additional information about this extremely important subject.<\/p>\n<p>CT, if you pipe the direct results of the <b>Get-Counter<\/b> cmdlet to the <b>Out-GridView<\/b> cmdlet, you end up with a complex object in the <i>CounterSamples <\/i>field. This effectively limits what you can do with the grid control. Here is an example of what you are probably attempting to do (I have used <b>ogv<\/b> as an alias for the <b>Out-GridView<\/b> cmdlet).<\/p>\n<p style=\"padding-left: 30px\">Get-Counter -ListSet processor | Get-Counter | ogv<\/p>\n<p>The resulting grid control is shown here. Note that when I attempt to use the filter for the grid control, nothing filters based on the string <i>User. <\/i>This indicates the inability of the grid control to effectively filter output.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6562.hsg-5-4-12-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6562.hsg-5-4-12-01.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<h2>Examine the members of the object<\/h2>\n<p>To provide the <b>Get-GridView<\/b> cmdlet with access to the specific counter information, it is first required to determine where the information resides. To look inside the <b>PerformanceCounterSampleSet<\/b> merely demands piping the result from the <b>Get-Counter<\/b> cmdlet to the <b>Get-Member<\/b> cmdlet. When we examine the members of the <b>PerformanceCounterSampleSet<\/b> object, two properties appear promising. The members of the <b>PerformanceCounterSampleSet <\/b>object are shown here.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-Counter -ListSet processor | Get-Counter -MaxSamples 1 | Get-Member<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; TypeName: Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType&nbsp;&nbsp;&nbsp;&nbsp; Definition<\/p>\n<p style=\"padding-left: 30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<\/p>\n<p style=\"padding-left: 30px\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool Equals(System.Object obj)<\/p>\n<p style=\"padding-left: 30px\">GetHashCode&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int GetHashCode()<\/p>\n<p style=\"padding-left: 30px\">GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type GetType()<\/p>\n<p style=\"padding-left: 30px\">ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToString()<\/p>\n<p style=\"padding-left: 30px\">CounterSamples Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.PowerShell.Commands.GetCounter.Performanc&#8230;<\/p>\n<p style=\"padding-left: 30px\">Timestamp&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.DateTime Timestamp {get;set;}<\/p>\n<p style=\"padding-left: 30px\">Readings&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptProperty System.Object Readings {get=$strPaths = &#8220;&#8221;&#8230;<\/p>\n<\/p>\n<p>The first property that appears promising is the <b>Readings<\/b><i> <\/i>property. To examine further the <b>Readings<\/b><i> <\/i>property, expand it and send the output to the <b>Get-Member<\/b> cmdlet. This technique is shown here.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-Counter -ListSet processor | Get-Counter -MaxSamples 1 | select -ExpandProperty readings | Get-Member<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; TypeName: System.String<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Definition<\/p>\n<p style=\"padding-left: 30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<\/p>\n<p style=\"padding-left: 30px\">Clone&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Object Clone()<\/p>\n<p style=\"padding-left: 30px\">CompareTo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int CompareTo(System.Object value), int Co&#8230;<\/p>\n<p style=\"padding-left: 30px\">Contains&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool Contains(string value)<\/p>\n<p style=\"padding-left: 30px\">CopyTo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void CopyTo(int sourceIndex, char[]&#8230;<\/p>\n<p style=\"padding-left: 30px\">EndsWith&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool EndsWith(string value), bool EndsWith&#8230;<\/p>\n<p style=\"padding-left: 30px\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool Equals(System.Object obj), bool Equal&#8230;<\/p>\n<p style=\"padding-left: 30px\">GetEnumerator&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.CharEnumerator GetEnumerator()<\/p>\n<p style=\"padding-left: 30px\">GetHashCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int GetHashCode()<\/p>\n<p style=\"padding-left: 30px\">GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type GetType()<\/p>\n<p style=\"padding-left: 30px\">GetTypeCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.TypeCode GetTypeCode()<\/p>\n<p style=\"padding-left: 30px\">IndexOf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int IndexOf(char value), int IndexOf(char &#8230;<\/p>\n<p style=\"padding-left: 30px\">IndexOfAny&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int IndexOfAny(char[] anyOf), int IndexOfA&#8230;<\/p>\n<p style=\"padding-left: 30px\">Insert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Insert(int startIndex, string value)<\/p>\n<p style=\"padding-left: 30px\">IsNormalized&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool IsNormalized(), bool IsNormalized(Sys&#8230;<\/p>\n<p style=\"padding-left: 30px\">LastIndexOf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int LastIndexOf(char value), int LastIndex&#8230;<\/p>\n<p style=\"padding-left: 30px\">LastIndexOfAny&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int LastIndexOfAny(char[] anyOf), int Last&#8230;<\/p>\n<p style=\"padding-left: 30px\">Normalize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Normalize(), string Normalize(Syste&#8230;<\/p>\n<p style=\"padding-left: 30px\">PadLeft&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string PadLeft(int totalWidth), string Pad&#8230;<\/p>\n<p style=\"padding-left: 30px\">PadRight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string PadRight(int totalWidth), string Pa&#8230;<\/p>\n<p style=\"padding-left: 30px\">Remove&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Remove(int startIndex, int count), &#8230;<\/p>\n<p style=\"padding-left: 30px\">Replace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Replace(char oldChar, char newChar)&#8230;<\/p>\n<p style=\"padding-left: 30px\">Split&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string[] Split(Params char[] separator), s&#8230;<\/p>\n<p style=\"padding-left: 30px\">StartsWith&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool StartsWith(string value), bool Starts&#8230;<\/p>\n<p style=\"padding-left: 30px\">Substring&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Substring(int startIndex), string S&#8230;<\/p>\n<p style=\"padding-left: 30px\">ToCharArray&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char[] ToCharArray(), char[] ToCharArray(i&#8230;<\/p>\n<p style=\"padding-left: 30px\">ToLower&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToLower(), string ToLower(System.Gl&#8230;<\/p>\n<p style=\"padding-left: 30px\">ToLowerInvariant Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToLowerInvariant()<\/p>\n<p style=\"padding-left: 30px\">ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToString(), string ToString(System&#8230;.<\/p>\n<p style=\"padding-left: 30px\">ToUpper&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToUpper(), string ToUpper(System.Gl&#8230;<\/p>\n<p style=\"padding-left: 30px\">ToUpperInvariant Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToUpperInvariant()<\/p>\n<p style=\"padding-left: 30px\">Trim&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Trim(Params char[] trimChars), stri&#8230;<\/p>\n<p style=\"padding-left: 30px\">TrimEnd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string TrimEnd(Params char[] trimChars)<\/p>\n<p style=\"padding-left: 30px\">TrimStart&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string TrimStart(Params char[] trimChars)<\/p>\n<p style=\"padding-left: 30px\">Chars&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ParameterizedProperty char Chars(int index) {get;}<\/p>\n<p style=\"padding-left: 30px\">Length&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Int32 Length {get;}<\/p>\n<\/p>\n<p>As you can see, the resulting objects are strings. The conversion to a string might be useful in some situations, but it does not facilitate additional processing as easily as a different type of object. Therefore, examine the <b>CounterSamples<\/b><i> <\/i>property. When it is piped to the <b>Get-Member<\/b> cmdlet, the <b>CounterSamples<\/b><i> <\/i>property appears much more interesting than a simple string. This technique is shown here.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-Counter -ListSet processor | Get-Counter -MaxSamples 1 | select -ExpandProperty countersamples | Get-Member -MemberType property<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; TypeName: Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/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\">CookedValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Double CookedValue {get;set;}<\/p>\n<p style=\"padding-left: 30px\">CounterType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.Diagnostics.PerformanceCounterType CounterType&#8230;<\/p>\n<p style=\"padding-left: 30px\">DefaultScale&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.UInt32 DefaultScale {get;set;}<\/p>\n<p style=\"padding-left: 30px\">InstanceName&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String InstanceName {get;set;}<\/p>\n<p style=\"padding-left: 30px\">MultipleCount&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.UInt32 MultipleCount {get;set;}<\/p>\n<p style=\"padding-left: 30px\">Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.String Path {get;set;}<\/p>\n<p style=\"padding-left: 30px\">RawValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.UInt64 RawValue {get;set;}<\/p>\n<p style=\"padding-left: 30px\">SecondValue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.UInt64 SecondValue {get;set;}<\/p>\n<p style=\"padding-left: 30px\">Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.UInt32 Status {get;set;}<\/p>\n<p style=\"padding-left: 30px\">TimeBase&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.UInt64 TimeBase {get;set;}<\/p>\n<p style=\"padding-left: 30px\">Timestamp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; System.DateTime Timestamp {get;set;}<\/p>\n<p style=\"padding-left: 30px\">Timestamp100NSec Property&nbsp;&nbsp; System.UInt64 Timestamp100NSec {get;set;}<\/p>\n<p>&nbsp;<\/p>\n<p>To test the <b>CounterSamples<\/b><i> <\/i>property to see if it contains the requisite information, use the command that is shown here.<\/p>\n<p style=\"padding-left: 30px\">Get-Counter -ListSet processor | Get-Counter -MaxSamples 1 | select -ExpandProperty countersamples &nbsp;| select path, timestamp, cookedvalue<\/p>\n<p>When the command runs, it displays the output shown here.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4073.hsg-5-4-12-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4073.hsg-5-4-12-02.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>To permit working with multiple performance counter sets, store the information that is gathered into a variable. When the variable contains the performance information, pipe the output to the <b>Out-GridView<\/b> cmdlet. (The <b>%<\/b> sign is an alias for the <b>Foreach-Object<\/b> cmdlet and <b>ogv<\/b> is an alias for <b>Out-GridView<\/b>).<\/p>\n<p style=\"padding-left: 30px\">$sample = Get-Counter -ListSet processor | Get-Counter -SampleInterval 1 -MaxSamples 10<\/p>\n<p style=\"padding-left: 30px\">$sample | % { $_.countersamples } | select path, timestamp, cookedvalue | ogv<\/p>\n<p>When the grid-view control appears, use either the quick <b>Filter<\/b><i> <\/i>or the <b>Add Criteria<\/b><i> <\/i>technique to parse the resulting performance information. The following image illustrates using the <b>Add Criteria<\/b><i> <\/i>technique to find only cooked values that are greater than 100 and paths that contain the word <i>interrupts. <\/i>Because the performance counter paths are very descriptive, it is easy to find the desired information.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5008.hsg-5-4-12-03.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5008.hsg-5-4-12-03.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>CT, that is all there is to using the <b>Out-GridView<\/b> cmdlet with performance counter information. Join me tomorrow for the Weekend Scripter.<\/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><b>Ed Wilson, Microsoft Scripting Guy<\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson demonstrates how to use the Out-GridView cmdlet with performance counter information. &nbsp;Hey, Scripting Guy! I have a question, and hopefully you will not think it is a stupid one. During the 2012 Scripting Games, one of the events had to do with using performance counters. I thought that was [&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":[51,60,3,4,45],"class_list":["post-9531","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-performance","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson demonstrates how to use the Out-GridView cmdlet with performance counter information. &nbsp;Hey, Scripting Guy! I have a question, and hopefully you will not think it is a stupid one. During the 2012 Scripting Games, one of the events had to do with using performance counters. I thought that was [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/9531","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=9531"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/9531\/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=9531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=9531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=9531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}