How to Find Performance Counters with PowerShell
One of the best ways to diagnose computer issues or even prevent them from happening is by monitoring performance metrics. For example, if your computer is using a lot of memory or CPU cycles without an obviously-known reason, that could be a good indication that your computer has a problem.
Likewise, you need to benchmark new applications for system performance. Monitoring performance metrics will provide a lot of data. In Windows, Performance Counters can help you do just that.
What are Performance Counters in Windows?
Windows performance counters are usage data regarding items such as 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 complains that their laptop is running slowly and demands a new device. This is a common complaint that nearly every IT tech support agent will face.
Support staff can use performance metrics to see the hardware utilization on that end user’s device. Even better, they can see the device's latency and response times. Using that data, tech support agents can see any issues and perform proper break-fix operations without throwing money at the problem.
Here’s another example. Say 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 load. You could use performance metrics to answer that question quickly.
What are the Benefits of Using Performance Counters?
There are many reasons why every IT pro should be comfortable monitoring system performance metrics. First, that data can be leveraged to fix a number 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 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 the 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 'perform’ in the Windows Search Bar. 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. It is located under the Administrative Tools area. Follow the directions below to find the Windows Performance Monitor snap-in.
Click the Start Button in Windows.
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.
Select Control Panel from the Start Menu.
Once the Control Panel opens, click on Administrative Tools.
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.
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 also use PowerShell to gather and monitor Windows Performance Metrics. 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 custom scripts to monitor a system’s performance.
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, which tell PowerShell which metrics to monitor.
For the rest of these steps, we will use the Get-Counter command in PowerShell. The Get-Counter command tells PowerShell which metrics to grab from which hardware components.
Use the ‘-ListSet*’ parameter to find the various performance counters that can be used with the Get-Counter commandlet. This will return a long list of all the performance counters available in Windows that PowerShell can use.
Using that parameter with Get-Counter will 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.
When you run the Get-Counter -ListSet * command, you will see that the CounterSetName entry also includes 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.
How to Use Data Collection Sets in Windows Performance Monitoring [Video]
In this video, Anthony Sequeira covers Data Collection Sets in Windows using the Performance Monitor tool (PERFMON). This can be a powerful method of collecting critical data regarding how your system is performing.
You’ll learn how to adjust these to examine the type of performance you want to investigate. This allows you to create data collection sets and set them up to run periodically.
Wrapping Up
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 for triaging issues and answering possible capacity questions. There are two ways to monitor Windows Performance Metrics: using the Performance Monitor GUI or pulling performance metrics with PowerShell.
The Windows Performance Monitor GUI is simple to find and use, while PowerShell allows you to quickly capture performance data and store it or manipulate it as needed.
Want to learn more about PowerShell? If so, you might be interested in the CBT Nuggets PowerShell training course.
delivered to your inbox.
By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.