Tuesday, January 20, 2009

CPU clock cycles

to list all processes running on a local machine that are using more CPU clock cycles than other processes

PS> Get-Process |
ForEach-Object `
{if ($_.cpu -lt 100)
{Write-Host $_.name, $_.cpu -foregroundcolor Yellow}
elseif ($_.cpu -gt 100)
{Write-Host $_.name, $_.cpu -foregroundcolor Cyan}}


We use an if statement to decide on the color of the text to display. If the amount of CPU time is less than 100, then the color of text is yellow. If it is more than 100, then we change the color of the text to cyan.

No comments:

Post a Comment