How to Use the typeperf Command to Write Performance Metrics to a File in Windows 11

Why Use typeperf?

When troubleshooting intermittent performance issues on a Windows 11 server or workstation, opening the graphical Performance Monitor (PerfMon) is the standard approach. However, if you are managing a fleet of headless servers, or if you need to script a lightweight performance logging tool that runs silently in the background via Task Scheduler, a graphical interface is not viable.

The typeperf command is a built-in Windows command-line utility that writes performance counter data directly to the command window or to a supported log file format (like CSV or TSV). It is incredibly lightweight and perfect for long-term diagnostic logging.

Step 1: Finding the Right Performance Counters

Before you can use typeperf, you need to know exactly what performance metrics (counters) you want to track. Because Windows tracks thousands of distinct metrics, you must query the available counters first.

Open a Command Prompt or PowerShell window as Administrator and run:

typeperf -q

This will flood the screen with every available counter. To find specific counters, use the findstr command to filter the output. For example, to find all counters related to memory, run:

typeperf -q | findstr /i "Memory"

You will see standard counters like \Memory\Available MBytes and \Memory\Pages/sec.

Step 2: Running a Basic Query

To view real-time data for a specific counter directly in your command window, use the following syntax:

typeperf "\Memory\Available MBytes"

The command will begin outputting the current available RAM in megabytes, updating exactly once per second. It will continue running indefinitely until you press Ctrl + C to stop it.

You can track multiple counters simultaneously by separating them with a space and enclosing each in quotation marks:

typeperf "\Memory\Available MBytes" "\Processor(_Total)\% Processor Time"

Step 3: Logging Data to a CSV File

The true power of typeperf is its ability to log data directly to a file for later analysis in Microsoft Excel or Power BI. To do this, use the -f flag to specify the format (CSV) and the -o flag to specify the output file path.

typeperf "\Processor(_Total)\% Processor Time" "\Memory\Available MBytes" -f CSV -o C:\temp\perflog.csv

Step 4: Controlling the Sample Rate and Duration

By default, typeperf samples data every 1 second and runs forever. If you are logging data over a 24-hour period, a 1-second interval will create a massive, unwieldy CSV file.

You can use the -si (sample interval) flag to change how often data is collected (in seconds), and the -sc (sample count) flag to determine exactly how many samples to take before the command automatically terminates.

For example, if you want to capture the CPU usage every 10 seconds, and you want it to run for exactly 60 samples (which equals 10 minutes total), you would run:

typeperf "\Processor(_Total)\% Processor Time" -si 10 -sc 60 -f CSV -o C:\temp\10min_cpu_log.csv

This command can easily be embedded into a .bat script and triggered via the Windows Task Scheduler to monitor system health during off-hours maintenance windows.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.