powershell - IIS6中哪个w3wp.exe进程属于哪个应用程序池(使用powershell)

标签 powershell iis-6

到目前为止,我使用这个工具来判断哪个 w3wp 属于哪个应用程序池

c:\windows\system32\cscript iisapp.vbs

如何使用 Powershell 提取相同的信息? 或者也许会得到更多信息丰富的结果。

谢谢:)

最佳答案

这绝不是唯一的方法,但这是我使用的一种方法。这是针对 PS v1 的,一些代码可以针对 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 
    }
}

输出:

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

iisapp 脚本显示如下:

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>

关于powershell - IIS6中哪个w3wp.exe进程属于哪个应用程序池(使用powershell),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2855978/

相关文章:

powershell - 使用脚本 block 远程调用Get-Process

windows - 在 Windows 上设置 Docker 化的命令行应用程序

performance - 在 Web 应用程序的压力测试期间记录性能时,我应该在 Windows 性能监视器中使用哪些计数器?

iis - IIS6.0可以托管两个SSL证书吗?

iis-6 - ASP.NET 中的 URL 重写而不重定向

powershell - 在 PowerShell 中,如何测试变量是否包含数值?

windows - 如何创建 Windows 服务来运行 powershell 脚本?

powershell - Cygwin 的交互式 Powershell

asp.net - 使用无 cookie session 时如何检测 session 超时

visual-studio - 我可以为 IIS6 的 w3wp.exe 设置进程标题吗?