Solved

Memory Mangement Powershell Script

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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