Hi,
I'd like to list top 5 process an which percentage of cpu/memory they use.
I will then use this to analyze remotely what processes are consuming cpu/memory instead of going via taskmgr.
I have these queries:
*$CPUTop5 = Get-WmiObject -computername $computername Win32_PerfFormattedData_PerfProc_Process| Sort-Object PercentProcessorTime -desc | Select-Object Name,PercentProcessorTime | where-object name -NE _Total | where-object name -NE Idle | Select-Object -First 5
*$MemTop5 = Get-WmiObject -computername $computername Win32_Process | Sort-Object WorkingSetSize -Descending | Select-Object Name,@{n='Private Memory(mb)';Expression = {[math]::round(($_.WorkingSetSize / 1mb), 2)}} | Select-Object -First 5
but $cputop5 shows chrome using 24 percent whereas in the taskmanager shows other values, same goes for memory.
So I looked further for other possibilities:
*Get-Process -ComputerName $ComputerName | Sort-Object CPU -desc | Select-Object -first 10 | Format-Table CPU,ProcessName but then would need to convert to percentage.
*Get-Counter -ComputerName localhost '\Process(*)\% Processor Time' `
| Select-Object -ExpandProperty countersamples `
| Select-Object -Property instancename, cookedvalue `
| Sort-Object -Property cookedvalue -Descending | Select-Object -First 10 | Where-Object InstanceName -ne _Total | Where-Object InstanceName -ne idle `
| Format-Table InstanceName,@{L='CPU';E={($_.Cookedvalue/100).toString('P')}} -AutoSize
So now I wonder what the approach is to get cpu top 5 and memory top 5 usage for processes so it correctly reflects what you see in taskmgr.
Please advise.
J.
I'd like to list top 5 process an which percentage of cpu/memory they use.
I will then use this to analyze remotely what processes are consuming cpu/memory instead of going via taskmgr.
I have these queries:
*$CPUTop5 = Get-WmiObject -computername $computername Win32_PerfFormattedData_PerfProc_Process| Sort-Object PercentProcessorTime -desc | Select-Object Name,PercentProcessorTime | where-object name -NE _Total | where-object name -NE Idle | Select-Object -First 5
*$MemTop5 = Get-WmiObject -computername $computername Win32_Process | Sort-Object WorkingSetSize -Descending | Select-Object Name,@{n='Private Memory(mb)';Expression = {[math]::round(($_.WorkingSetSize / 1mb), 2)}} | Select-Object -First 5
but $cputop5 shows chrome using 24 percent whereas in the taskmanager shows other values, same goes for memory.
So I looked further for other possibilities:
*Get-Process -ComputerName $ComputerName | Sort-Object CPU -desc | Select-Object -first 10 | Format-Table CPU,ProcessName but then would need to convert to percentage.
*Get-Counter -ComputerName localhost '\Process(*)\% Processor Time' `
| Select-Object -ExpandProperty countersamples `
| Select-Object -Property instancename, cookedvalue `
| Sort-Object -Property cookedvalue -Descending | Select-Object -First 10 | Where-Object InstanceName -ne _Total | Where-Object InstanceName -ne idle `
| Format-Table InstanceName,@{L='CPU';E={($_.Cookedvalue/100).toString('P')}} -AutoSize
So now I wonder what the approach is to get cpu top 5 and memory top 5 usage for processes so it correctly reflects what you see in taskmgr.
Please advise.
J.
Jan Hoedt