Solved

Memory Mangement Powershell Script

Posted on 2011-09-28
1
335 Views
Last Modified: 2012-05-12
I need a script to do the following:


•      List any processes running on a machine over 100 meg of ram but under 200 meg
o      Show the name of process
o      Colour them orange
o      Using a for or foreach loop
•      List any processes running on your machine over 200 meg
o      Show the name of the process, company, product and path
o      Colour these red
o      Using the “where” pipeline command
•      Display a set of totals after displaying these two lists
o      Total processes running
o      Total “orange” processes
o      Total “red” processes

I know I need to use the get-process cmdlet like so:

$a = Get-Process | Where-Object {$_.WS -gt 100000000} | where-object {$_.WS -lt 200000000} | sort-object ProcessName | format-table -property ProcessName

and bang them into an array as well as format them with write-output, but I'm not sure how!
0
Comment
Question by:jaxstorm
1 Comment
 
LVL 18

Accepted Solution

by:
x-men earned 500 total points
Comment Utility
$a = Get-Process | Where-Object {$_.WS -gt 100000000}
$a | % {if ($a.WS -lt 200000000) {Write-Host $_.ProcessName -ForegroundColor yellow}}
$a | % {if ($a.WS -gt 200000000) {Write-Host $_.ProcessName -ForegroundColor red}}
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now