Solved

Powershell to monitor IIS AppPool & formatting the results

Posted on 2014-02-10
2
1,668 Views
Last Modified: 2014-02-10
Hi all,
I am attempting to create a PowerShell script that I will ultimately plug into our application monitoring system;
Specifically, I am looking to create a script that will identify a specific IIS application pool, and then return the amount of memory used by that pool's worker process. I pretty much have it getting what I need, but in order to integrate this with our monitoring solution I need to format the output of the script a bit...
Here is what I have:
$serverName=$args[0]
$applicationPoolName=$args[1]
$memUsed = Get-WmiObject Win32_process -ComputerName $serverName | where CommandLine -Match $applicationPoolName | fl VM

Open in new window


So, I call this script from a PowerShell prompt:
CheckAppPool.ps1 servername appPoolName

The results are returned as:
VM  :  123456789

I need to figure out a way to have the results returned to me so they look like this:
memUsed 123456789

Any assistance is greatly appreciated!!

Thanks,

David
0
Comment
Question by:nacAdmin
[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
2 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39848360
Try the following:
$memUsed = Get-WmiObject Win32_process -ComputerName $serverName | where CommandLine -Match $applicationPoolName | ForEach { "memUsed {0}" -f $_.VM }

Open in new window

0
 

Author Closing Comment

by:nacAdmin
ID: 39848370
Awesome! Thanks so much!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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 …
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…

730 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