A Top Challenge for PowerShell Scripters

The Chairman feels his last challenge took it easy on you, so he has commissioned a new PowerShell scripting challenge for advanced users. Do you have what it takes to be an Iron Scripter? The Chairman will decide after seeing what you can do with this exercise.

In Linux, there is a command called top, which provides system and process information. The screen refreshes every few seconds until the user presses break out of the display.

top sample from Linux

Your challenge is to write a PowerShell function that duplicates, or at least as close as possible, the functionality of top, but for Windows platforms. You can omit information where there is no Windows equivalent. Your command should include the following functionality:

  • Let the user specify the refresh rate.
  • Let the user specify the formatting unit for memory usage, i.e. MB or GB.
  • Let the user specify which process owners to display.
  • Let the user specify the number of processes to show based on some criteria.

For truly advanced PowerShell scripters, add these features to your command:

  • Run remotely and show the computer name. You should support credentials.
  • Allow the user to save and use a configuration file.
  • Allow the user to specify a timeout value.
  • Allow the user to specify processes by name.
  • Or add support for any other top feature of your choosing.

The Chairman looks forward to your solutions. As always, submit links to your solutions in the comments. Good luck.