# encoding: ascii
# api: powershell
# title: Get-ProcessorGraph
# description: Shows CPU utilization till $host height size
# version: 0.1
# type: function
# author: greg zakharov
# license: CC0
# function: Get-ProcessorGraph
# x-poshcode-id: 4693
# x-archived: 2013-12-14T07:27:23
# x-published: 2013-12-12T13:38:00
#
#
#function Get-ProcessorGraph {
begin {
$pc = New-Object Diagnostics.PerformanceCounter("Processor", "% Processor Time", "_Total")
$raw = $host.UI.RawUI
function strip([Int32]$x, [Int32]$y, [Int32]$z, [ConsoleColor]$bc) {
$pos = $raw.WindowPosition;$pos.X += $x;$pos.Y += $y
$row = $raw.NewBufferCellArray(@(' ' * $z), $bc, $bc)
$raw.SetBufferContents($pos, $row)
}
}
process {
for ($i = 0; $i -lt $raw.WindowSize.Height; $i++) {
strip 0 $i ([Math]::Round(($pc.NextValue() * 100 / $raw.WindowSize.Width + 1))) 'Green'
sleep -s 1
}
}
end {
cls
}
#}