Link to home
Start Free TrialLog in
Avatar of nacAdmin
nacAdmin

asked on

Powershell to monitor IIS AppPool & formatting the results

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
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nacAdmin
nacAdmin

ASKER

Awesome! Thanks so much!