how to get current Highest Active Time in powershell RRS feed

  • Question

  • Hi,

    how can i get the current Highest Active Time like i see in Resource Monitor via PowerShell?


    • Edited by Medasystem Thursday, November 21, 2019 3:36 PM
    Thursday, November 21, 2019 3:34 PM

All replies

  • help get-counter -online


    Thursday, November 21, 2019 3:41 PM
  • i've this script in powershell that check Highest Active Time but the problem is when the Highest Active Time is 100% in resource monitor the script return numbers greater then 100. why?

    $Sleep=10 $Idle1=$DiskTime1=$T1=$Idle2=$DiskTime2=$T2=1 $Disk = Get-WmiObject -class Win32_PerfRawData_PerfDisk_LogicalDisk ` -filter "name= 'C:' " [Double]$Idle1 = $Disk.PercentIdleTime [Double]$DiskTime1 = $Disk.PercentDiskTime [Double]$T1 = $Disk.TimeStamp_Sys100NS start-Sleep $Sleep $Disk = Get-WmiObject -class Win32_PerfRawData_PerfDisk_LogicalDisk ` -filter "name= 'C:' " [Double]$Idle2 = $Disk.PercentIdleTime [Double]$DiskTime2 = $Disk.PercentDiskTime [Double]$T2 = $Disk.TimeStamp_Sys100NS $PercentIdleTime =[math]::Round((($Idle2 - $Idle1) / ($T2 - $T1)) * 100) $PercentDiskTime =[math]::Round((($DiskTime2 - $DiskTime1) / ($T2 - $T1)) * 100)


    Sunday, November 24, 2019 10:55 AM
  • As I noted - the time will never match. If your number is gr4eater than 100% then your math is wrong.

    Have you asked the author of the script to fix it for you?

    I would also note that the method does not calculate disk usage as you are tak9ing two averages and adding them. Averages cannot be averaged.

    If you want to see qhy this won't work just run the following:

    Get-WmiObject Win32_PerfRawData_PerfDisk_LogicalDisk -filter "name= 'C:' " |

    Select PercentIdleTime,PercentDiskTime,TimeStamp_Sys100NS

    Now run this:

    Get-WmiObject Win32_PerfFormattedData_PerfDisk_LogicalDisk -filter "name= 'C:' " |
        Select PercentIdleTime,PercentDiskTime


    • Edited by jrv Sunday, November 24, 2019 11:21 AM
    Sunday, November 24, 2019 11:16 AM
  • The following will give you the best answer:

    Get-Counter '\PhysicalDisk(0 C: K:)\% Idle Time

    Your system may have a different counter name.

    To get all disk counter do this:

    Get-Counter -ListSet PhysicalDisk | select -expand PathsWithInstances


    • Edited by jrv Sunday, November 24, 2019 11:26 AM
    Sunday, November 24, 2019 11:25 AM
  • The following will give you an idea of what a live disk looks like over time:

    Get-Counter '\PhysicalDisk(0 C: K:)\% Idle Time' -Continuous | 
    select @{n='CookedValue';e={$_.CounterSamples.CookedValue}}


    • Edited by jrv Sunday, November 24, 2019 11:29 AM
    Sunday, November 24, 2019 11:29 AM