iis - 如何在 % { dir IIS :\AppPools\$_. Name } 中创建一个 For..Each 值?

标签 iis wmi powershell-2.0 application-pool worker-process

这是行不通的

>目录 IIS:\AppPools\| % { dir IIS:\AppPools\$_.Name\WorkerProcesses }

更多信息

我想使用Powershell来获取每个应用程序池的PID。我知道我可以使用 WMI 来获取类似以下命令的信息,但我正在尝试使用 Powershell 的 WebAdministration 模块。

WMI 方法(工作示例)

Get-WmiObject -NameSpace 'root\WebAdministration' -class 'WorkerProcess' -ComputerName 'host' |选择 AppPoolName、ProcessId | ft -a

AppPoolName                   ProcessId
-----------                   ---------
MSExchangePowerShellAppPool        5432
MSExchangeServicesAppPool          3604
MSExchangeOWAAppPool               7056
MSExchangeAutodiscoverAppPool      6012
DefaultAppPool                     3288
MSExchangeSyncAppPool              2944

Powershell 方法(不是工作示例..帮助!)

如何组合两个命令的输出(可能作为一行)来同时提供每个应用程序池的 PID?

[PS] C:\Windows\system32>import-module WebAdministration
[PS] C:\Windows\system32>dir IIS:\AppPools

Name                     State        Applications
----                     -----        ------------
Classic .NET AppPool     Started
DefaultAppPool           Started      Default Web Site
                                      /Rpc
                                      /RpcWithCert
                                      /ArchiveProxy
MSExchangeAutodiscoverAp Started      /Autodiscover
pPool                                 /Autodiscover/bin
                                      /Autodiscover/help
MSExchangeECPAppPool     Started      /ecp
MSExchangeOWAAppPool     Started      /owa
                                      /owa/oma
                                      /ArchiveProxyOwa
MSExchangeOWACalendarApp Started      /owa/Calendar
Pool
MSExchangePowerShellAppP Started      /PowerShell
ool
MSExchangeServicesAppPoo Started      /EWS
l                                     /EWS/bin
MSExchangeSyncAppPool    Stopped      /Microsoft-Server-ActiveSync

我要组合的第二个查询是这样的:

[PS] C:\Windows\system32>dir IIS:\AppPools\DefaultAppPool\WorkerProcesses  | fl


processId : 3904
Handles   : 89516
state     : Running
StartTime : 2/19/2013 10:34:57 PM

最佳答案

你只需扩展你需要的属性:

dir IIS:\AppPools\ |select -expand name| % { dir IIS:\AppPools\$_\WorkerProcesses } 

关于iis - 如何在 % { dir IIS :\AppPools\$_. Name } 中创建一个 For..Each 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14992678/

相关文章:

c# - 可以在 IIS 中对静态 html 页面进行后处理吗?

c# - 以编程方式区分自签名证书和 CA 签名证书 - IIS 绑定(bind)

.net - 在单个 Web 应用程序上具有多个域的 IIS

powershell - 将数组分配给 Powershell 中的字典条目

validation - PowerShell : GetNewClosure() and Cmdlets with validation

amazon-web-services - HTTPS 域显示空白页面,而 HTTP 工作正常

c++ - 距离 Windows 挂起的剩余时间

c# - WMI : the installation package is not accessible form the remote machine 远程安装问题

Java 和 Hyper-V

PowerShell - "Delete all files from this folder except one"的最紧凑方式