Skip to main content
Applied syntax highlighting ; Removed content not relevant to answer
Source Link
JW0914
  • 8.3k
  • 7
  • 31
  • 50
 

This commentcomment from Mark should get more recommendation, because it does almost exactly what the question was and it works:

Provides the nice headings at the top with every update without needing to clear the entire console.

$saveY = [console]::CursorTop
$saveX = [console]::CursorLeft      

while ($true) {
    Get-Process | Sort -Descending CPU | Select -First 30;
    Sleep -Seconds 2;
    [console]::setcursorposition($saveX,$saveY+3)
}

(link to comment: https://superuser.com/a/770455/989044 )

You should make a simple module for it and host in on github or provide it with choco. I think it should be a standart module in the first place, because it's heavily searched on google and there are all kinds of workarounds but none of them are so elegant and near to linux top command.

Sorry for posting it like this, but because of the strikt rules in here it's impossible to comment or make a note without 50 karma or so.

  • Provides the nice headings at the top with every update without needing to clear the entire console.

    $saveY = [console]::CursorTop
    $saveX = [console]::CursorLeft      
    
    while ($true) {
      Get-Process | Sort -Descending CPU | Select -First 30;
      Sleep -Seconds 2;
      [console]::setcursorposition($saveX,$saveY+3)
    }
    

This comment from Mark should get more recommendation, because it does almost exactly what the question was and it works:

Provides the nice headings at the top with every update without needing to clear the entire console.

$saveY = [console]::CursorTop
$saveX = [console]::CursorLeft      

while ($true) {
    Get-Process | Sort -Descending CPU | Select -First 30;
    Sleep -Seconds 2;
    [console]::setcursorposition($saveX,$saveY+3)
}

(link to comment: https://superuser.com/a/770455/989044 )

You should make a simple module for it and host in on github or provide it with choco. I think it should be a standart module in the first place, because it's heavily searched on google and there are all kinds of workarounds but none of them are so elegant and near to linux top command.

Sorry for posting it like this, but because of the strikt rules in here it's impossible to comment or make a note without 50 karma or so.

 

This comment from Mark should get more recommendation because it does almost exactly what the question was and it works:

  • Provides the nice headings at the top with every update without needing to clear the entire console.

    $saveY = [console]::CursorTop
    $saveX = [console]::CursorLeft      
    
    while ($true) {
      Get-Process | Sort -Descending CPU | Select -First 30;
      Sleep -Seconds 2;
      [console]::setcursorposition($saveX,$saveY+3)
    }
    
Source Link

This comment from Mark should get more recommendation, because it does almost exactly what the question was and it works:

Provides the nice headings at the top with every update without needing to clear the entire console.

$saveY = [console]::CursorTop
$saveX = [console]::CursorLeft      

while ($true) {
    Get-Process | Sort -Descending CPU | Select -First 30;
    Sleep -Seconds 2;
    [console]::setcursorposition($saveX,$saveY+3)
}

(link to comment: https://superuser.com/a/770455/989044 )

You should make a simple module for it and host in on github or provide it with choco. I think it should be a standart module in the first place, because it's heavily searched on google and there are all kinds of workarounds but none of them are so elegant and near to linux top command.

Sorry for posting it like this, but because of the strikt rules in here it's impossible to comment or make a note without 50 karma or so.