Which w3wp.exe process belongs to which App Pool in IIS6 (with powershell)

拈花ヽ惹草 提交于 2019-12-11 06:14:51

问题


to date, I use this tool to tell which w3wp belongs to which App Pool

c:\windows\system32\cscript iisapp.vbs

How can I extract the same information with Powershell? Or maybe, with more informative results.

Thanks :)


回答1:


This is by no means the only approach, but here is one I use. This is for PS v1, some code can be optimized for V2.

function get-apppools{
    [regex]$pattern="-ap ""(.+)"""
    gwmi win32_process -filter 'name="w3wp.exe"' | % {
        $name=$_.name
        $cmd = $pattern.Match($_.commandline).Groups[1].Value
        $procid = $_.ProcessId
        New-Object psobject | Add-Member -MemberType noteproperty -PassThru Name $name |
            Add-Member -MemberType noteproperty -PassThru AppPoolID $cmd |
            Add-Member -MemberType noteproperty -PassThru PID $procid 
    }
}

This outputs:

PS C:\Documents and Settings\jpogran> get-apppools

Name                                    AppPoolID                                                                   PID
----                                    ---------                                                                   ---
w3wp.exe                                SharePoint - 9090                                                          6988
w3wp.exe                                SharePoint - 80                                                            6364
w3wp.exe                                foo.bar.net                                                            4720
w3wp.exe                                SharePoint Central Administration v3                                       7960
w3wp.exe                                SharePoint - 8181                                                          7756

The iisapp script shows this:

PS C:\Documents and Settings\jpogran> iisapp
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

W3WP.exe PID: 6988   AppPoolId: SharePoint - 9090
W3WP.exe PID: 6364   AppPoolId: SharePoint - 80
W3WP.exe PID: 4720   AppPoolId: foo.bar.net
W3WP.exe PID: 7960   AppPoolId: SharePoint Central Administration v3
W3WP.exe PID: 7756   AppPoolId: SharePoint - 8181
PS C:\Documents and Settings\jpogran>


来源:https://stackoverflow.com/questions/2855978/which-w3wp-exe-process-belongs-to-which-app-pool-in-iis6-with-powershell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!