Skip to content

xWebConfigPropertyCollection

Johan Ljunggren edited this page Dec 6, 2023 · 2 revisions

xWebConfigPropertyCollection

Important

This resource has been renamed in the latest release, see WebConfigPropertyCollection. Bug fixes and new functionality will only be added to the renamed resource.

Parameters

Parameter Attribute DataType Description Allowed Values
WebsitePath Key String Path to website location (IIS or WebAdministration format).
Filter Key String Filter used to locate property collection to update.
CollectionName Key String Name of the property collection to update.
ItemName Key String Name of the property collection item to update.
ItemKeyName Key String Name of the key of the property collection item to update.
ItemKeyValue Key String Value of the key of the property collection item to update.
ItemPropertyName Key String Name of the property of the property collection item to update.
ItemPropertyValue Write String Value of the property of the property collection item to update.
Ensure Write String Indicates if the property and value of the property collection item should be present or absent. Defaults to Present. Present, Absent

Description

The xWebConfigPropertyCollection DSC resource is used to ensure the value of an identified property collection item's property in the web.config file.

Builds upon the deprecated xWebConfigKeyValue resource to support all web.config elements that contain collections of child items.

Requirements

  • Target machine must be running Windows Server 2012 R2 or later.

Known issues

All issues are not listed here, see here for all open issues.

Examples

Example 1

Disables the HTTP TRACE method at the server level.

This example shows how to use the xWebConfigPropertyCollection DSC resource for adding a configuration element. It will add an "add" element to the system.webServer/security/requestFiltering/verbs collection to disable the HTTP TRACE verb.

Configuration Sample_xWebConfigPropertyCollection_Add
{
    param
    (
        # Target nodes to apply the configuration.
        [Parameter()]
        [String[]]
        $NodeName = 'localhost'
    )

    # Import the modules that define custom resources
    Import-DscResource -ModuleName xWebAdministration

    Node $NodeName
    {
        xWebConfigPropertyCollection "$($NodeName) - Disable HTTP TRACE method"
        {
            WebsitePath       = 'MACHINE/WEBROOT/APPHOST'
            Filter            = 'system.webServer/security/requestFiltering'
            CollectionName    = 'verbs'
            ItemName          = 'add'
            ItemKeyName       = 'verb'
            ItemKeyValue      = 'TRACE'
            ItemPropertyName  = 'allowed'
            ItemPropertyValue = 'false'
            Ensure            = 'Present'
        }
    }
}

Example 2

Removes disabling the HTTP TRACE method at the server level.

This example shows how to use the xWebConfigPropertyCollection DSC resource for removing a configuration element. It will remove the "add" element from the system.webServer/security/requestFiltering/verbs collection (if present) for disabling the HTTP TRACE verb.

Configuration Sample_xWebConfigPropertyCollection_Remove
{
    param
    (
        # Target nodes to apply the configuration.
        [Parameter()]
        [String[]]
        $NodeName = 'localhost'
    )

    # Import the modules that define custom resources
    Import-DscResource -ModuleName xWebAdministration

    Node $NodeName
    {
        xWebConfigPropertyCollection "$($NodeName) - Remove disabling HTTP TRACE method"
        {
            WebsitePath       = 'MACHINE/WEBROOT/APPHOST'
            Filter            = 'system.webServer/security/requestFiltering'
            CollectionName    = 'verbs'
            ItemName          = 'add'
            ItemKeyName       = 'verb'
            ItemKeyValue      = 'TRACE'
            ItemPropertyName  = 'allowed'
            ItemPropertyValue = 'false'
            Ensure            = 'Absent'
        }
    }
}