Created
February 15, 2025 14:48
-
-
Save psitem/a0bd07aaa61fa1665819d47b374d8b82 to your computer and use it in GitHub Desktop.
Output total disk read/write activity in MB/s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Counter -Counter "\LogicalDisk(_Total)\Disk Read Bytes/sec","\LogicalDisk(_Total)\Disk Write Bytes/sec" -Continuous -SampleInterval 1 | ForEach-Object { | |
[PSCustomObject]@{ | |
Time = (get-date $_.Timestamp -Format u).replace("Z", "") | |
Read = [math]::round($_.CounterSamples[0].CookedValue /1Mb, 0) | |
Write = [math]::round($_.CounterSamples[1].CookedValue /1Mb, 0) | |
} | |
} |
This is another variation I use on a system with dozens of disks where I want to see the aggregate disk activity along with the activity on individual disks, ignoring disks with < 1KB/s.
$first=$true ; Get-Counter -Counter "\LogicalDisk(*)\Disk Read Bytes/sec","\LogicalDisk(*)\Disk Write Bytes/sec" -Continuous -SampleInterval 1 | ForEach-Object {
$dt = ( get-date $_.Timestamp -Format u ).replace( "Z", "" )
$cs = ( $_.CounterSamples | Sort-Object InstanceName,Path )
for ( $i=0; $i -lt $cs.count; $i+=2 ) {
if ( ( $first -eq $true ) -or ( ( $cs[$i].CookedValue -gt 1024 ) -or ( $cs[$i+1].CookedValue -gt 1024 ) ) ) {
[PSCustomObject]@{
Time = $dt
Instance = $cs[$i].InstanceName
Read = [math]::round( $cs[$i].CookedValue /1Mb, 0 )
Write = [math]::round( $cs[$i+1].CookedValue /1Mb, 0 )
}
}
}
$first = $false
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output: