dir iis:\apppools
提供 3 个属性:名称、状态和应用程序。
我想隔离“应用程序”,但由于某种原因,它在获取成员列表中无处可寻。
TypeName: Microsoft.IIs.PowerShell.Framework.ConfigurationElement#system.applicationHost/applicationPools#add
Name MemberType Definition
---- ---------- ----------
Recycle CodeMethod void Recycle()
Start CodeMethod void Start()
Stop CodeMethod void Stop()
applicationPoolSid CodeProperty Microsoft.IIs.PowerShell.Framework.CodeProperty
state CodeProperty Microsoft.IIs.PowerShell.Framework.CodeProperty
ClearLocalData Method void ClearLocalData()
Copy Method void Copy(Microsoft.IIs.PowerShell.Framework.ConfigurationElement ...
Delete Method void Delete()
Equals Method bool Equals(System.Object obj), bool IEquatable[ConfigurationEleme...
GetAttribute Method Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute GetAttri...
GetAttributeValue Method System.Object GetAttributeValue(string attributeName)
GetChildElement Method Microsoft.IIs.PowerShell.Framework.ConfigurationElement GetChildEl...
GetCollection Method Microsoft.IIs.PowerShell.Framework.ConfigurationElementCollection ...
GetHashCode Method int GetHashCode()
GetMetadata Method System.Object GetMetadata(string metadataType)
GetParentElement Method Microsoft.IIs.PowerShell.Framework.ConfigurationElement GetParentE...
GetType Method type GetType()
LoadProperties Method void LoadProperties(System.Collections.Generic.Dictionary[string,S...
SetAttributeValue Method void SetAttributeValue(string attributeName, System.Object value)
SetMetadata Method void SetMetadata(string metadataType, System.Object value)
ToPSObject Method psobject ToPSObject(Microsoft.IIs.PowerShell.Framework.Configurati...
ToString Method string ToString()
Update Method void Update(Microsoft.IIs.PowerShell.Framework.ConfigurationElemen...
UpdateCollection Method bool UpdateCollection(psobject[] arr)
autoStart NoteProperty System.Boolean autoStart=True
CLRConfigFile NoteProperty System.String CLRConfigFile=
cpu NoteProperty Microsoft.IIs.PowerShell.Framework.ConfigurationElement#add#cpu cp...
enable32BitAppOnWin64 NoteProperty System.Boolean enable32BitAppOnWin64=False
enableConfigurationOverride NoteProperty System.Boolean enableConfigurationOverride=True
failure NoteProperty Microsoft.IIs.PowerShell.Framework.ConfigurationElement#add#failur...
ItemXPath NoteProperty System.String ItemXPath=/system.applicationHost/applicationPools/a...
managedPipelineMode NoteProperty System.String managedPipelineMode=Classic
managedRuntimeLoader NoteProperty System.String managedRuntimeLoader=webengine4.dll
managedRuntimeVersion NoteProperty System.String managedRuntimeVersion=v4.0
name NoteProperty System.String name=ASP.NET v4.0
passAnonymousToken NoteProperty System.Boolean passAnonymousToken=True
processModel NoteProperty Microsoft.IIs.PowerShell.Framework.ConfigurationElement#add#proces...
PSChildName NoteProperty System.String PSChildName=ASP.NET v4.0
PSDrive NoteProperty System.Management.Automation.PSDriveInfo PSDrive=IIS
PSIsContainer NoteProperty System.Boolean PSIsContainer=True
PSParentPath NoteProperty System.String PSParentPath=WebAdministration::\\MED1-WEB\AppPools
PSPath NoteProperty System.String PSPath=WebAdministration::\\MED1-WEB\AppPools\ASP.NE...
PSProvider NoteProperty Microsoft.IIs.PowerShell.Provider.IIsProviderInfo PSProvider=WebAd...
queueLength NoteProperty System.Int64 queueLength=1000
recycling NoteProperty Microsoft.IIs.PowerShell.Framework.ConfigurationElement#add#recycl...
startMode NoteProperty System.String startMode=OnDemand
workerProcesses NoteProperty Microsoft.IIs.PowerShell.Framework.ConfigurationElement#add#worker...
Item ParameterizedProperty System.Object Item(string attributeName) {get;set;}
Attributes Property Microsoft.IIs.PowerShell.Framework.ConfigurationAttributeCollectio...
ChildElements Property Microsoft.IIs.PowerShell.Framework.ConfigurationChildElementCollec...
ElementTagName Property string ElementTagName {get;}
Methods Property Microsoft.IIs.PowerShell.Framework.ConfigurationMethodCollection M...
Schema Property Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema Sche...
我错过了什么?
答案1
将以下内容保存到文件 Get-AppsInAppPool.ps1 中并按如下方式调用:
Get-AppsInAppPool -appPool "My Pool Name"
param([string]$appPool)
import-module webadministration
$apps = (Get-WebConfigurationProperty "/system.applicationHost/sites/site/application[`
@applicationPool='$appPool']" "machine/webroot/apphost" -name path).ItemXPath
foreach ($s in $apps) {
$name = $s -replace "\/system.applicationHost\/sites\/site\[\@name='", ""
$name = $name -replace "' and \@id='\d{1,10}'\]\/application\[\@path='", ""
$name = $name -replace "'\]",""
$out += $name + "`n"
}
$out