Prof. Powershell

Show What You Learned About PowerShell

Homework Assignment #1: Creating a formatted report of a selected scoped of peak paged memory.

If you've been in class from the beginning you should have learned quite a bit about PowerShell by now. So I think it is time for a homework assignment. Before the next column, see if you can figure out how to do this in PowerShell:

Create a formatted report of the top 10 processes where the peak paged memory is greater than 10MB. For each process select its process id, name, paged memory, peak paged memory, working set and peak working set sizes.

You should be able to write a single PowerShell command to accomplish this task. I hope you realize that you'll need to send objects from one cmdlet to another through the pipeline.

Let me give you a few more hints. First, you'll need to know the right property names for a process object. Do you remember what cmdlet will show you an object's members, such as methods and properties? That's right -- Get-Member. Pipe Get-Process to Get-Member to find the right property names.

I'm asking you to filter the process objects where the peak paged memory size is greater than 10MB and then select the top 10 based on peak paged memory size. The filtering is probably unnecessary in a production-oriented script, but I wanted to fill out the exercise.

Here's another hint: You'll need to select items in descending order after they are sorted. To display a nicely formatted report, you'll likely need to use the Format-Table cmdlet. If you read this paragraph closely you should detect some hints as to what cmdlets to use.

I encourage you to review the help file for all the cmdlets you are likely to need to complete the assignment. You should write the most complete and efficient PowerShell expression you can. There may be several ways to finish this assignment. I'll be back next week with a possible solution.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular

Upcoming Training Events

0 AM
Live! 360 Orlando
November 17-22, 2024
TechMentor @ Microsoft HQ
August 11-15, 2025