Solved

Memory Mangement Powershell Script

Posted on 2011-09-28
1
338 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

11 Experts available now in Live!

Get 1:1 Help Now