How to know idle time for process running in system

2.5k Views Asked by At

All,

I am using windows 7 os

I would like to know the idle time for each application or process running in my machine.

Ex: I opened one process like notepad.exe but I am not working on it from last 5 minutes, I need to get the idle time as 5 minutes for the process.

like that at one time I would like to know the idle time of all process running in my machine.
I tried the below code but I am not getting the any data for IdleTime

$processname = Get-Process | Select-Object -Property ProcessName, IdleTime,ID,WS

Please help me

1

There are 1 best solutions below

0
On

There seems to be no property named Idletime. You can check that out by doing:

Get-Process | Get-Member -force

Perhaps parsing the WMI Win32_Process could help you achieve your goal? Try this:

$kerneltime = Get-WmiObject Win32_Process -Filter "Name='System idle process'" | Select KernelModeTime
$timeSpan = (new-object System.TimeSpan $kerneltime.KernelModeTime)