Solved

Memory Mangement Powershell Script

Posted on 2011-09-28
1
341 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
getting combo box selected item into variable 9 45
Exchange powershell help 4 25
Exchange powershell help 2 30
get list of Security Groups of Bulk users 9 22
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This article will help you understand what HashTables are and how to use them in PowerShell.
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

778 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