Sudheej
Sudheej

Reputation: 2029

Compute CPU % for w3wp.exe in powershell

I am developing a script which fetches CPU time for w3wp.exe i need to compute the actual CPU percentage used by the process and not CPU time, using get-process i get only the CPU time. Please let me know the computation steps for getting cpu percentage used just like how its displayed in task-bar using power-shell

Note: I dont want to use gwmi since script response is very slow. I want to use this app in a performance test enviornment and dont want to apply any load on processing.

 get-wmiobject Win32_PerfFormattedData_PerfProc_Process

Upvotes: 0

Views: 1932

Answers (1)

mjolinor
mjolinor

Reputation: 68341

How about using Get-Counter:

get-counter '\Process(powershell*)\% Processor Time' 

Upvotes: 2

Related Questions