Installed PowerGadgets and tried the very first sample: ProcessCPUTime.ps1 from the Samples directory:
get-process | select name, CPU | sort TotalProcessorTime | out-chart -Values CPU -Label Name -title "Process CPU Time"
I get a chart, but not sorted. This is obvious, cause the select cmdlet does not specify TotalProcessorTime (exact same graph is displayed when I specify: sort blabla)
So I add TotalProcessorTime to the select cmdlet:
get-process | select name, CPU, TotalProcessorTime | sort TotalProcessorTime | out-chart -Values CPU -Label Name -title "Process CPU Time"
This time I get the chart bars sorted, but also:
Select-Object : Exception getting "TotalProcessorTime": "Access is denied"At line:1 char:21+ get-process | select <<<< name, CPU, TotalProcessorTime | sort TotalProcessorTime -desc | out-chart -Values CPU -Label Name -title "Process CPU Time"
The problem seems to be caused by the Idle process, as shown by:
get-process | select name, cpu, totalprocessorTime
FrameworkService 51.953125 00:00:51.9531250GoogleToolbarNotifier 0.953125 00:00:00.9531250Select-Object : Exception getting "TotalProcessorTime": "Access is denied"At line:1 char:21+ get-process | select <<<< name, cpu, totalprocessorTimeIdleiexplore 44.765625 00:00:44.7656250
The statement below does the job, but what is the reason for the error? Running all this as the Administrator on a Windows XP SP2 machine.
get-process | where { $_.name -ne "Idle" } | select name, CPU, TotalProcessorTime | sort TotalProcessorTime -desc | out-chart -Values CPU -Label Name -title "Process CPU Time"