Solved

Powershell to monitor IIS AppPool & formatting the results

Posted on 2014-02-10
2
1,516 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

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.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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