header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
System.Diagnostics.PerformanceCounter & NextValue
Last Post 25 Aug 2009 06:31 AM by MI. 0 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
MIUser is Offline
New Member
New Member
Posts:9
Avatar

--
25 Aug 2009 06:31 AM
    Hello all,
       I'm trying to create a powershell script that can monitor the CPU usage of a process.
    The sample below is what I've come up with but I'm always returning a 0 value, even when getting consecutive samples.
    Any help would be most appreciated. I know I have to be missing something simple...


    	  
    $ProcessName = "taskmgr"
    $CPUPerfCounter = New-Object System.Diagnostics.PerformanceCounter("Process","% Processor Time",$ProcessName)
    $CPUTime = $CPUPerfCounter.NextValue() #/ $env:NUMBER_OF_PROCESSORS
    Start-Sleep 1
    $CPUTime
    Start-Sleep 1
    $CPUTime
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer