Solved

Memory Mangement Powershell Script

Posted on 2011-09-28
1
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
x-men earned 500 total points
ID: 36716982
$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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

615 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