Solved

Powershell to monitor IIS AppPool & formatting the results

Posted on 2014-02-10
2
1,388 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
2 Comments
 
LVL 39

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

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 explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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