dingemans Posted September 27, 2007 Report Share Posted September 27, 2007 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" Quote Link to comment Share on other sites More sharing options...
valdezdj Posted September 27, 2007 Report Share Posted September 27, 2007 Not sure why you are getting the error. But to get rid of it try: get-process | select name, CPU, TotalProcessorTime -ea silentlycontinue | sort TotalProcessorTime | out-chart -Values CPU -Label Name -title "Process CPU Time" This is just an erroraction that tells the error not to show up. You can also put in a -refresh 00:00:01 and the error will not show up. HTH,valdezdj Quote Link to comment Share on other sites More sharing options...
dingemans Posted September 27, 2007 Author Report Share Posted September 27, 2007 -ea silentlycontinue Yep, that does the trick. Thanx! That's to say, it suppresses the error message. Anyone else an idea what causes the error in the first place? Quote Link to comment Share on other sites More sharing options...
dingemans Posted September 27, 2007 Author Report Share Posted September 27, 2007 For the broader audience... The link below describes the probable cause of the error: http://blogs.msdn.com/powershell/archive/2006/04/30/586973.aspx Seems that the Idle process has no TotalProcessorTime (nor StartTime, and perhaps more), Back to the initial sample that ships with PowerGadgets. I'd suggest to sort on another property, not sort at all, or get rid of the idle process as in a previous reply. Quote Link to comment Share on other sites More sharing options...
marco.shaw Posted September 28, 2007 Report Share Posted September 28, 2007 Another example of the issue: http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=33709 I've not been able to find anything "official", but as you mention, it appears the idle process object has different properties. Thanks for pointing this out. I had never tried this combination of properties. Did you still want to graph this object? I'm sure there's a workaround to manually calculating some of the values and graphing them along with the others. Marco Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.