I want an application or script that displays the following: Worker process, App pool name, memory usage, and optionally cpu usage. I am familiar with using

%windir%\system32\inetsrv\appcmd.exe list wp

but this just gets me the workerproces id and the app pool name. I then take that and cross reference taskmanager. This works, but I would like a quicker - almost dashboard like display of the information. I imagine there must be some sort of solution that shows the information without needing to click around like process explorer. Anyone have something in particular they use? Would this be possible in powershell?

3 Answers 3


If you don't have IIS 7 and the provider, you can use WMI. The attached script works for most of your requirements, except CPU usage. Save the below script as get-webserverapppoolstats.ps1 (or whatever you want).

You can run the script then with:

./Get-WebServerAppPoolStats.ps1 'Server1', 'Server2', 'Server3' -IntegratedAuthentication OR Get-Content servers.txt | ./Get-WebServerAppPoolStats.ps1 -IntegratedAuthentication

param (
    $webserver = $null,

    $path = $MyInvocation.MyCommand.Path

    if ($webserver -ne $null)
        if ($IntegratedAuthentication)
            $webserver | &$path -IntegratedAuthentication
            $webserver | &$path -username $username -password $password
    $OFS = ', '
    $Fields = 'CommandLine', 'Name', 'CreationDate', 'ProcessID', 'WorkingSetSize', 'ThreadCount', 'PageFileUsage', 'PageFaults' 

    $query = @"
    Select $fields
    From Win32_Process
    Where name = 'w3wp.exe'

    $AppPool =  @{Name='Application Pool';Expression={($_.commandline).split(' ')[-1]}}
    $Process = @{Name='Process';Expression={$_.name}}
    $RunningSince = @{Name='Running since';Expression={[System.Management.ManagementDateTimeconverter]::ToDateTime($_.creationdate)}}
    $Memory = @{Name='Memory Used';Expression={'{0:#,#}' -f $_.WorkingSetSize}}
    $Threads = @{Name='Thread Count';Expression={$_.threadcount}}
    $PageFile = @{Name='Page File Size';Expression={'{0:#,#}' -f $_.pagefileusage}}
    $PageFaults = @{Name='Page Faults';Expression={'{0:#,#}' -f $_.pagefaults}} 

    $server = $_ 

    if ($server -ne $null)
        if ($IntegratedAuthentication)
            $result = Get-WmiObject -Query $query -ComputerName $server
            $securepassword = ConvertTo-SecureString $password -AsPlainText -Force
            $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securepassword

            $result = Get-WmiObject -Query $query -ComputerName $server -Credential $cred 

        $Server = @{Name='Server';Expression={$server}}
        $result | Select-Object $Server, $AppPool, $Process, $RunningSince, $Memory, $Threads, $PageFile, $pageFaults
  • I changed $AppPool = @{Name='Application Pool';Expression={($_.commandline).split('"')[-2]}} so it works with app pools with spaces in their names.
    – notandy
    Dec 30, 2010 at 19:43

Yes powershell can do this with the new powershell provider for IIS it's easy. Here are some of the examples from the run time data walkthru's provided:

AppPool State

PS IIS:\> cd AppPools
PS IIS:\AppPools> Get-WebItemState DemoAppPool
PS IIS:\AppPools> Stop-WebItem DemoAppPool
PS IIS:\AppPools> Get-WebItemState DemoAppPool

Worker Processes and Requests The get-process cmdlet doesn't help you figuring out which Application Pool a particular worker process is serving. This can be easily done however:

PS IIS:\AppPools> dir DefaultAppPool\WorkerProcesses

               processId                  Handles                    state StartTime
               ---------                  -------                    
                   6612                      326                        1 3/28/2008 12:20:27 PM

note that once you have the PID regular

   get-process -id pid

will tell you the memory usage


I dont know why the Server 'name' part of this script didn't work for me, but i came up with a workaround:

replace this line:

$Server = @{Name='Server';Expression={$server}}

with these two lines:

$machine = New-Object system.string $server

$Server = @{Name='Server';Expression={$machine}}

once i did this, it worked perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.