Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Use diskperf.exe in Windows 11 to Monitor Disk Performance

Monitoring disk performance is crucial for maintaining the health and efficiency of your Windows 11 system. One of the tools available for this purpose is diskperf.exe. This command-line utility allows you to enable or disable disk performance counters, which are essential for gathering performance data.

Examples:

Enabling Disk Performance Counters

To start monitoring disk performance, you need to enable the disk performance counters. Follow these steps:

  1. Open Command Prompt as Administrator:

    • Press Win + S to open the search bar.
    • Type cmd.
    • Right-click on Command Prompt and select Run as administrator.
  2. Enable Disk Performance Counters:

    • In the Command Prompt window, type the following command and press Enter:
      diskperf -y
    • This command enables the disk performance counters for all drives.

Disabling Disk Performance Counters

If you no longer need to monitor disk performance, you can disable the counters to save system resources:

  1. Open Command Prompt as Administrator:

    • Follow the same steps as above to open Command Prompt with administrative privileges.
  2. Disable Disk Performance Counters:

    • In the Command Prompt window, type the following command and press Enter:
      diskperf -n
    • This command disables the disk performance counters for all drives.

Checking Disk Performance Status

To check the current status of disk performance counters, you can use the following command:

  1. Open Command Prompt as Administrator:

    • Follow the same steps as above to open Command Prompt with administrative privileges.
  2. Check Status:

    • In the Command Prompt window, type the following command and press Enter:
      diskperf
    • This command will display the current status of disk performance counters.

Using PowerShell for Disk Performance Monitoring

While diskperf.exe is a useful tool, PowerShell offers more advanced capabilities for monitoring disk performance. Here’s how you can use PowerShell to gather disk performance data:

  1. Open PowerShell as Administrator:

    • Press Win + X and select Windows PowerShell (Admin).
  2. Get Disk Performance Data:

    • In the PowerShell window, type the following command and press Enter:
      Get-Counter -Counter "\PhysicalDisk(*)\*" | Format-Table
    • This command retrieves and displays various disk performance metrics in a table format.

Automating Disk Performance Monitoring

You can create a script to automate the process of monitoring disk performance using PowerShell. Here’s a sample script:

  1. Create a PowerShell Script:

    • Open Notepad and paste the following script:

      $outputFile = "C:\disk_performance_log.txt"
      $counters = "\PhysicalDisk(*)\*"
      $interval = 5
      $samples = 12
      
      Get-Counter -Counter $counters -SampleInterval $interval -MaxSamples $samples | 
      Export-Csv -Path $outputFile -NoTypeInformation
    • Save the file with a .ps1 extension, for example, disk_performance_monitor.ps1.
  2. Run the Script:

    • Open PowerShell as Administrator.
    • Navigate to the directory where the script is saved.
    • Execute the script by typing:
      .\disk_performance_monitor.ps1

This script will collect disk performance data at 5-second intervals for a total of 12 samples and save the results to a CSV file.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.