
The Chairman is back with another PowerShell scripting challenge. He would also like to remind you that all of his challenges are open-ended. There is no deadline and he hopes people will work on them as they discover them or feel up to the challenge. Today’s challenge is no different. The goal is to use PowerShell to achieve a specific task but it doesn’t require a function or production-level script. At the very least you should write a few PowerShell commands to achieve the desired result. If you feel inspired to wrap them up into a PowerShell function, you are more than welcome to do so.
The Chairman would like to know, given a specific process, what percent of total in-use memory is it using? For the sake of this challenge, you can focus on the WorkingSet value. For example, if a process has a WorkingSet value of 120MB and 12GB of memory is in use, the process is using 0.1 percent. It is assumed these will be small percentages so you might want to format them to a set number of decimal points.
The Chairman would like you to get information by process name and necessarily an individual process ID. If you are running Firefox, you may have multiple Firefox processes. Treat them as a single entry. How much memory is Firefox using and what percentage of total in use memory?
It is up to you to decided what information to display, but these values are a good start:
- Process name
- Total number of processes
- Total WorkingSet
- Percentage of in-use memory
Again, you don’t have to create a function or script. All that is required are the PowerShell commands you would run to get a result.
Bonus
For more experienced PowerShell scripters, you can tackle these bonus elements.
- Create a PowerShell function around your code
- Support querying a remote computer
- Provide sorted results
- Provide formatted output
- Services run in a process so create a command to report on the same memory usage for a given service. It is OK if the service shares a process. Although you might want to indicate that.
The Chairman looks forward to seeing comments with links to your work.
Simple solution. https://github.com/ralphmwr/MemoryUse
I’ll work on some of the bonus stuff next.
This is my first Iron Scripter Challenge, and I love it. I learn be doing and I enjoy a challenge. I liked it so much I blogged about it which something I haven’t done in a long while.
Anyway find my blog post here which breaks down my solution and links to my github repository:
https://huntingwithps.blogspot.com/2021/01/process-memory-utilization-iron.html
Since this is my first, I’d really appreciate feedback. Thanks.
Here’s my approach. https://jdhitsolutions.com/blog/powershell/8143/solving-the-powershell-memory-challenge/