Author Posts

March 15, 2016 at 8:55 am

I am trying to get continuous disk IOPS on a server, but trying to forego the results from continuing to scroll down the screen. Instead, I'd like to clear the screen between samples to gather, and if possible do the same in an out-gridview view as well.

$c="\PHysicalDisk(*)\Disk Reads/sec"
get-counter -counter $c -computername server1 -continuous -sampleinterval 5

March 15, 2016 at 9:21 am

you could use this endless loop that was provided here: http://powershell.com/cs/blogs/tips/archive/2016/03/11/cleverly-aborting-endless-loop.aspx

Then make a script similar to this:

 
$c="\PHysicalDisk(*)\Disk Reads/sec"
$displaycount = 20
try
{
    do
    {
        $i+=$i
        $counter = get-counter -counter $c -sampleinterval 5
        if($i -eq $displaycount)
        {
            cls
            $i = 0
        }
        write-output $counter
    }while($true)
}
catch
{
  $sapi = New-Object -ComObject Sapi.SpVoice
  $sapi.Speak('Hey, you aborted me dammit!')
}

March 15, 2016 at 9:22 am

This will not work with Out-Gridview, but you could "refresh" you console window with this

$ComputerName = 'server1'
$Counter = '\PHysicalDisk(*)\Disk Reads/sec' 
$SampleInterval = 5

Get-Counter -Counter $Counter -ComputerName $ComputerName -SampleInterval $SampleInterval -Continuous | ForEach-Object {
    Clear-Host
    $_
}

March 15, 2016 at 9:24 am

There is no inherent way within that cmdet.

while ($true) { cls; get-counter -counter $c -computername util1; sleep 5 }

EDIT: Oops. Essentially the same as above. He was just quicker.

March 15, 2016 at 11:46 am

Thanks all for your quick responses. I love this community and how much we are all willing to help each other out. I've tried Christian's solution and it looks like it will work for me.