To get the disk performance using PowerShell, we need to use the Performance counter of the disk. There are performance counters available for the Physical disk or the logical disk. To check what the disks related counter sets are available we can use the below command,
PS C:\> Get-Counter -ListSet "*disk*" | Select CounterSetName
CounterSetName -------------- FileSystem Disk Activity Storage Spaces Virtual Disk LogicalDisk PhysicalDisk
We will use a Logical disk to get more information about it. We will retrieve its counter first.
Get-Counter -ListSet LogicalDisk | Select -ExpandProperty Counter
We need to retrieve the Disk read time counter,
Get-Counter -Counter '\LogicalDisk(*)\% Disk Read Time'
The below command will retrieve the 2 sample counts with 2 sample intervals.
Get-Counter -Counter '\LogicalDisk(*)\% Disk Read Time' -MaxSamples 2 -SampleInterval 2
To get the continuous intervals, use the below command.
Get-Counter -Counter '\LogicalDisk(*)\% Disk Read Time' -Continuous