Get-IISConfigCollection

Gets a configuration collection object from an IIS configuration section or a configuration element.

Syntax

Get-IISConfigCollection
   [-ConfigElement] <ConfigurationElement>
   [[-CollectionName] <String>]
   [<CommonParameters>]

Description

The Get-IISConfigCollection cmdlet gets a ConfigurationCollection object from either a ConfigurationSection or a ConfigurationElement.

It is advisable to not to assign this value to a parameter and pass it in the pipeline to the next cmdlet since Windows PowerShell cannot interpret this object. This is due to the fact that ConfigurationCollection implements IEnumerable and the pipeline processor enumerates each single element when used this way. Instead either pass the whole Get-IISConfigCollection cmdlet in the pipeline or pass it as a parameter.

Examples

Example 1: Get a configuration collection from an IIS configuration element

PS C:\> Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files"

Attributes      : {value}
ChildElements   : {}
ElementTagName  : add
IsLocallyStored : True
Methods         : 
RawAttributes   : {[value, Default.htm]} 
Schema          : Microsoft.Web.Administration.ConfigurationElementSchema

Attributes      : {value}
ChildElements   : {}
ElementTagName  : add
IsLocallyStored : True
Methods         : 
RawAttributes   : {[value, Default.asp]} 
Schema          : Microsoft.Web.Administration.ConfigurationElementSchema

This command gets the Files Collection for the system.webServer/defaultDocument section.

Example 2: Get a configuration element from an IIS configuration section

PS C:\> Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigElement -ChildElementName "files" | Get-IISConfigCollection


Attributes      : {value}
ChildElements   : {}
ElementTagName  : add
IsLocallyStored : True
Methods         : 
RawAttributes   : {[value, Default.htm]} 
Schema          : Microsoft.Web.Administration.ConfigurationElementSchema

Attributes      : {value}
ChildElements   : {}
ElementTagName  : add
IsLocallyStored : True
Methods         : 
RawAttributes   : {[value, Default.asp]} 
Schema          : Microsoft.Web.Administration.ConfigurationElementSchema

This command gets the Files Element configuration object from the system.webServer/defaultDocument section then gets its default collection. The output of the two formats are the same.

Parameters

-CollectionName

Specifies the name of the collection to be returned. If the name of the collection is not used, the Default Collection is returned. Alternatively, the named collection can be retrieved by Get-IISConfigElement then the default collection inside this element can be retrieved.

Type:String
Position:2
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ConfigElement

Specifies the IIS ConfigurationSection or ConfigurationElement for which the ConfigurationCollection is returned.

Type:ConfigurationElement
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

ConfigurationElement

String

Outputs

Object