Certifications / Microsoft

How to Find Performance Counters with PowerShell

by Jon Welling
How to Find Performance Counters with PowerShell picture: A
Published on April 15, 2022

One of the best ways to diagnose computer issues or even prevent them from happening is by monitoring performance metrics. For example, suppose your computer is using a lot of memory or CPU cycles, and you aren’t doing anything with it. In that case, that could be a good indication that your computer has a problem.

Likewise, suppose you need to benchmark new applications for system performance. In that case, monitoring performance metrics will give you a lot of data.

What are Performance Counters in Windows

Windows performance counters are usage data regarding things like processor cycles, memory, and storage disks. By measuring finite usage at any given moment, systems administrators can monitor system performance. That system performance data can be invaluable, yet it’s not often used.

Let’s say an end-user is complaining that their laptop is running slowly and is demanding a new device. This is a common complaint that every IT tech support agent will run into. Support staff can use performance metrics to see the hardware utilization on that end user’s device. Even better, they can see what latency and response times that device is offering. Using that data, tech support agents can triage the laptop appropriately, see its issues, and perform proper break-fix operations without throwing money at the problem.

Here’s another example. Suppose that you need to deploy another network-based application in your business. You have some capacity open on a VM running on ESXi on one of your servers. You aren’t sure whether that VM currently has enough hardware resources assigned to it to handle an additional application’s load. You could use these performance metrics to answer that question quickly.

There are a ton of reasons why every IT pro should be comfortable with monitoring system performance metrics. First, that data is beneficial and can be leveraged to fix a variety of issues. Best of all, IT pros don’t need to sit in front of a computer to collect this data.

Like many Windows-based admin utilities, performance metrics can be gathered and monitored remotely. In addition, Microsoft offers GUI-based panel snap-ins and command-line tools that can grab performance data from remote machines. This is especially useful if enterprising IT pros want to create a remote monitoring tool to capture and store performance data for administrative reasons.

I mean, wouldn’t it be fun to build your own script that can monitor a server for high CPU or memory usage and shoot you an alert if that occurs? That’s taking your IT skills to the next level.

How to Find Windows Performance Metrics

Windows includes a way to monitor system performance metrics through both a GUI and through the command line. Let’s discuss how to find these performance metrics.

There are two ways to find the Performance Monitor snap-in in Windows. You can either use the run dialogue box or find the snap-in through the control panel.

The directions below will work for Windows 8, Windows 8.1, Windows 10, and Windows 11. The instructions are similar for Windows 7, but since Windows 7 is now end-of-life, we will not discuss it in detail.

How to Launch the Windows Performance Monitor From Start Menu

Running the Windows Performance Monitor from the Run Dialogue box in the Windows Start Menu is easy. Click the start button

  1. Start typing ‘Perfmon.’ You do not need to type this in a specific box. The Windows Start Menu will automatically populate these results. The Windows Search mechanism will populate an option called ‘Performance Monitor’ in the Start Menu.

  2. Select Performance Monitor to run it.

How to Find the Windows Performance Monitor in the Windows Control Panel

Finding the Windows Performance Monitor in the Control Panel is easy. The Performance Monitor will be located under the Administrative Tools area. Follow the directions below to find the Windows Performance Monitor snap-in.

  1. Click the Start Button in Windows.

  2. Type’ Control Panel’ in the Start Menu. You can just begin typing once the Start Menu opens. You do not need to open a special dialogue box.

  3. Select Control Panel from the Start Menu.

  4. Once the Control Panel opens, click on Administrative Tools.

  1. If you do not see Administrative Tools, change the ‘View By’ options in the top-right corner of the Control Panel Window to either Large Icons or Small Icons.

  1. The Windows Performance Monitor will be located within the Administrative Tools area of the Windows Control Panel.

How to Find Performance Counters with PowerShell for Windows

You can use PowerShell to gather and monitor Windows Performance Metrics, too. PowerShell can be a more helpful way of gathering Windows performance metrics than the GUI snap-in because that performance data can be piped into other applications or databases. That means you can create your own custom scripts to monitor a system’s performance as you need.

Using PowerShell to monitor performance metrics is a little more complicated than using the Performance Monitor GUI. Before you can monitor system performance, you need to find the performance counters first. These performance counters tell PowerShell which metrics to monitor.

We will be using the Get-Counter commandlet in PowerShell for the rest of these steps. The Get-Counter commandlet tells PowerShell what metrics to grab from which hardware components.

To find the various performance counters that can be used with the Get-Counter commandlet, use the ‘-ListSet *’ parameter. This will return a long list of all the performance counters available in Windows that PowerShell can use.

Using that parameter with Get-Counter is going to return a lot of information, though. You can use filters in PowerShell if you are looking for specific counters. For example, if you only want performance counters related to networking, you could use the command below:

Get-Counter -ListSet * | Where-Object -FilterScript { $PSItem.countersetname -match ‘network’}

By piping the results of the Get-Counter commandlet into the Where-Object function, you can filter the results. That still returns a lot of results, though. Suppose you want to display a much more manageable list of counters. In that case, you can filter those results further with the Select-Object command:

Get-Counter -ListSet * | Where-Object -FilterScript { $PSItem.countersetname -match 'network'} | Select-Object -Property CounterSetName

Adding the Select-Object commandlet will return a much smaller, easier to parse list. 

Digressing, when you run the Get-Counter -ListSet * command, you will see the CounterSetName entry will also include a handful of Counter parameters. Using one of those parameters with the Get-Counter commandlet will return performance metrics. 

For this example, let’s say we want to get the total bytes from the network adapter in our computer. Use the command below:

Get-Counter ‘\Network Adapter(*)\Bytes Total/sec’ That will return the byte metrics for our network cards. 

That’s it! That’s how you pull performance metrics with PowerShell.

An Overview of How to Find Performance Counters with PowerShell [Video]

In this video, Trevor Sullivan covers how to find Performance Counters with PowerShell. After showing you where to get started in his GitHub repository, he will walk you through where to find the various Performance Counters available in Windows and then how to select which ones you want to track.

Wrapping Up

Do you want to learn more about PowerShell? If so, you might be interested in an entire PowerShell training course. PowerShell is the de facto command-line environment and scripting language for Windows administration, so consider investing in yourself and learning new skills. 

Monitoring performance metrics in Windows can be a powerful tool to triage issues and answer possible capacity questions. There are two ways you can monitor Windows Performance Metrics. First, you can use the Performance Monitor GUI or pull performance metrics with PowerShell.

To use the Windows Performance Monitor GUI, navigate to the Control Panel in Windows. Then head to the Administrative Tools area. The Performance Monitor GUI is in that area of the Windows Control Panel.

To use performance metrics in PowerShell, use the Get-Counter commandlet. You can find the counters available in Windows by using the -ListSet * parameter with Get-Counter. Using that parameter will list each performance counter available as well as those counter’s paths. Then, use the performance counter path with the Get-Counter commandlet to dump performance metrics to the PowerShell console.

Using PowerShell to grab performance metrics can be powerful. Because PowerShell is a whole scripting language, you can quickly capture performance data and store it or manipulate it as needed. 


Download

Download

Ultimate Systems Administration Cert Guide

A 158-page guide to every Microsoft, VMware, Citrix, AWS, Google, and Linux certification, and how they fit into your career.

By submitting this form you agree that you have read, understood, and are able to consent to our privacy policy.


Don't Miss Out

Get great content delivered to your inbox.

I have read and understood the privacy policy, and am able to consent to it.

Recommended Articles

Get CBT Nuggets IT training news and resources

I have read and understood the privacy policy and am able to consent to it.

© 2022 CBT Nuggets. All rights reserved.Terms | Privacy Policy | Accessibility | Sitemap | 2850 Crescent Avenue, Eugene, OR 97408 | 541-284-5522