{"id":7872,"date":"2020-11-12T11:02:17","date_gmt":"2020-11-12T16:02:17","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7872"},"modified":"2020-11-12T11:02:24","modified_gmt":"2020-11-12T16:02:24","slug":"better-performance-counters-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/","title":{"rendered":"Better Performance Counters with PowerShell"},"content":{"rendered":"\n<p>I wanted to tell you about another addition to the latest release of the <a href=\"https:\/\/github.com\/jdhitsolutions\/PSScriptTools\" target=\"_blank\" rel=\"noreferrer noopener\">PSScriptTools <\/a>module. This is something I've written about before but I decided to add the function to the module. I hope you find it a much easier way to work with performance counters. And it works in Windows PowerShell and PowerShell 7.x.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Get-Counter<\/h2>\n\n\n\n<p>We've had the Get-Counter cmdlet in PowerShell for a very long time. However, I have always had a slight problem with the way it displays results.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"382\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-1024x382.png\" alt=\"\" class=\"wp-image-7873\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-1024x382.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-300x112.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-768x287.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-1536x574.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-850x317.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default.png 1992w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The command writes an interesting object to the pipeline.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"434\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-all-1024x434.png\" alt=\"\" class=\"wp-image-7874\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-all-1024x434.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-all-300x127.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-all-768x325.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-all-1536x650.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-all-850x360.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-all.png 1859w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Under the hood, PowerShell is using a custom format file to render results in an easy to read view. But if you want to do something with the output like export to a csv file, you need to jump through hoops.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Get-Counter | Select-Object -expand Countersamples | Select-Object Timestamp,Path,InstanceName,CookedValue,@{Name=\"Computername\";Expression={$_.path.split(\"\\\")[2].toUpper()}} | Export-Csv c:\\work\\counters.csv<\/code><\/pre>\n\n\n\n<p>This is certainly not intuitive. I wanted a performance counter cmdlet that wrote \"better\" structured data to the pipeline.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Get-MyCounter<\/h2>\n\n\n\n<p>The PSScriptTools module now includes an updated version of my <a href=\"https:\/\/github.com\/jdhitsolutions\/PSScriptTools\/blob\/master\/docs\/Get-MyCounter.md\" target=\"_blank\" rel=\"noreferrer noopener\">Get-MyCounter<\/a> function. This function is a \"wrapper\" around Get-Counter that writes simple, structured objects to the pipeline. You can use it in almost the same say as Get=Counter.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"238\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-1-1024x238.png\" alt=\"\" class=\"wp-image-7875\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-1-1024x238.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-1-300x70.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-1-768x179.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-1-1536x357.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-1-850x198.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-1.png 2025w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The custom object has its own formatting file. But the object type is easy to use.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"985\" height=\"543\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/mycounter-member.png\" alt=\"\" class=\"wp-image-7876\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/mycounter-member.png 985w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/mycounter-member-300x165.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/mycounter-member-768x423.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/mycounter-member-850x469.png 850w\" sizes=\"auto, (max-width: 985px) 100vw, 985px\" \/><\/figure>\n\n\n\n<p>Now, I have a much easier way to work with performance counter data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"280\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-2-1024x280.png\" alt=\"\" class=\"wp-image-7877\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-2-1024x280.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-2-300x82.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-2-768x210.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-2-1536x420.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-2-2048x560.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-2-850x232.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In fact, I can get counters from Get-Counter and pipe them to Get-MyCounter.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"604\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-3-1024x604.png\" alt=\"\" class=\"wp-image-7878\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-3-1024x604.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-3-300x177.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-3-768x453.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-3-850x501.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-mycounter-3.png 1284w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Get-MyCounter also supports sampling.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">get-counter -list system | get-mycounter -MaxSamples 10 -SampleInterval 2<\/code><\/pre>\n\n\n\n<p>Or you could use ConvertTo-WPFGrid, also from the PSScriptTools module, and let it handle the sampling.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$counters = (get-counter -list system).counter | where {$_ -match \"file\"}\nGet-MyCounter -Counter $counters -ComputerName prospero,thinkp1 | \nSelect-Object * -exclude Instance | \nConvertTo-WPFGrid -Title \"System Performance\" -Timeout 6 -refresh -UseLocalVariable counters<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"595\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/counters-form.png\" alt=\"\" class=\"wp-image-7879\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/counters-form.png 843w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/counters-form-300x212.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/counters-form-768x542.png 768w\" sizes=\"auto, (max-width: 843px) 100vw, 843px\" \/><\/figure>\n\n\n\n<p>The form will refresh every 6 seconds until I close it. The form also runs in its own runspace so there is no prompt blocking.<\/p>\n\n\n\n<p>I hope you'll give Get-MyCounter a try and let me know what you think.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to tell you about another addition to the latest release of the PSScriptTools module. This is something I&#8217;ve written about before but I decided to add the function to the module. I hope you find it a much easier way to work with performance counters. And it works in Windows PowerShell and PowerShell&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Better Performance Counters with #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[340,534],"class_list":["post-7872","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-get-counter","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Better Performance Counters with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here&#039;s a better way to get performance counter information in PowerShell that write a better object to the pipeline.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Better Performance Counters with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s a better way to get performance counter information in PowerShell that write a better object to the pipeline.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-12T16:02:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-12T16:02:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-1024x382.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Better Performance Counters with PowerShell\",\"datePublished\":\"2020-11-12T16:02:17+00:00\",\"dateModified\":\"2020-11-12T16:02:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/\"},\"wordCount\":300,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/get-counter-default-1024x382.png\",\"keywords\":[\"Get-Counter\",\"PowerShell\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/\",\"name\":\"Better Performance Counters with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/get-counter-default-1024x382.png\",\"datePublished\":\"2020-11-12T16:02:17+00:00\",\"dateModified\":\"2020-11-12T16:02:24+00:00\",\"description\":\"Here's a better way to get performance counter information in PowerShell that write a better object to the pipeline.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/get-counter-default.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/get-counter-default.png\",\"width\":1992,\"height\":744},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7872\\\/better-performance-counters-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Better Performance Counters with PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Better Performance Counters with PowerShell &#8226; The Lonely Administrator","description":"Here's a better way to get performance counter information in PowerShell that write a better object to the pipeline.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Better Performance Counters with PowerShell &#8226; The Lonely Administrator","og_description":"Here's a better way to get performance counter information in PowerShell that write a better object to the pipeline.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-11-12T16:02:17+00:00","article_modified_time":"2020-11-12T16:02:24+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-1024x382.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Better Performance Counters with PowerShell","datePublished":"2020-11-12T16:02:17+00:00","dateModified":"2020-11-12T16:02:24+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/"},"wordCount":300,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-1024x382.png","keywords":["Get-Counter","PowerShell"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/","name":"Better Performance Counters with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default-1024x382.png","datePublished":"2020-11-12T16:02:17+00:00","dateModified":"2020-11-12T16:02:24+00:00","description":"Here's a better way to get performance counter information in PowerShell that write a better object to the pipeline.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/get-counter-default.png","width":1992,"height":744},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Better Performance Counters with PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1874,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1874\/background-performance-counters\/","url_meta":{"origin":7872,"position":0},"title":"Background Performance Counters","author":"Jeffery Hicks","date":"December 6, 2011","format":false,"excerpt":"Windows Powershell makes it relatively easy to collect performance counter information via the Get-Counter cmdlet. Because I'm assuming you want to collect more than a few seconds of performance information, you'll need to take advantage of PowerShell background jobs if you want your prompt back. Of course, you can always\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/12\/listcounters-300x206.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6308,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6308\/ultimate-powershell-telemetry-prompt\/","url_meta":{"origin":7872,"position":1},"title":"The Ultimate PowerShell Telemetry Prompt","author":"Jeffery Hicks","date":"December 20, 2018","format":false,"excerpt":"Well, I knew I wouldn't be satisfied. The other day I shared a PowerShell prompt function that could display telemetry like information for a few remote servers. One of the drawbacks was the limited amount of information I could display. I've revised that function and have a new version that\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-15.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-15.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-15.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-15.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5005,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5005\/memory-reporting-with-powershell\/","url_meta":{"origin":7872,"position":2},"title":"Memory Reporting with PowerShell","author":"Jeffery Hicks","date":"May 20, 2016","format":false,"excerpt":"I've started a new project and I'm hoping a few of you will give it a spin and let me know how it works for you. I've created a PowerShell module called MemoryTools that uses a few WMI classes and performance counters to provide insight into memory utilization and configuration\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"show-memoryusage","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/show-memoryusage_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/show-memoryusage_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/show-memoryusage_thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":7471,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7471\/a-powershell-network-monitor\/","url_meta":{"origin":7872,"position":3},"title":"A PowerShell Network Monitor","author":"Jeffery Hicks","date":"May 12, 2020","format":false,"excerpt":"I hope you've been trying your hand at the scripting challenges being posted on the Iron Scripter website. The challenges are designed for individuals to do on their own to build up their PowerShell scripting skills. A few weeks ago, a challenge was posted to create a network monitoring tool\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/netperf-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/netperf-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/netperf-2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/netperf-2.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/netperf-2.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1750,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1750\/friday-fun-perf-counters-with-write-progress\/","url_meta":{"origin":7872,"position":4},"title":"Friday Fun Perf Counters with Write-Progress","author":"Jeffery Hicks","date":"November 11, 2011","format":false,"excerpt":"While working on my course for TrainSignal on managing Windows Servers with PowerShell, I came up with an interesting use of the Write-Progress cmdlet. I was working on the performance monitoring lesson and realized I could use Write-Progress as rudimentary graphing tool. The cmdlet has a parameter that lets you\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8027,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8027\/powershell-modules-in-a-cross-version-world\/","url_meta":{"origin":7872,"position":5},"title":"PowerShell Modules in a Cross-Version World","author":"Jeffery Hicks","date":"January 14, 2021","format":false,"excerpt":"The other day I was helping a friend sort out some module-related questions. While helping him, I realized his questions and problems were not unique. Now that many of us are running Windows PowerShell 7 side-by-side, what are the implications when it comes to using PowerShell modules? What are the\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/module-locations.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/module-locations.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/module-locations.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/module-locations.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/module-locations.png?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=7872"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7872\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}