Skip to content
dscbot edited this page Nov 11, 2023 · 1 revision

xWindowsFeatureSet

Parameters

Parameter Attribute DataType Description Allowed Values
Name Required System.String[] The name of the roles or features to install or uninstall.
Ensure Write System.String Specifies whether the roles or features should be installed or uninstalled.

To install the features, set this property to Present. To uninstall the features, set this property to Absent. | Present, Absent | | Source | Write | System.String | | | | IncludeAllSubFeature | Write | System.Boolean | Specifies whether or not all subfeatures should be installed or uninstalled alongside the specified roles or features.

If this property is true and Ensure is set to Present, all subfeatures will be installed. If this property is false and Ensure is set to Present, subfeatures will not be installed or uninstalled. If Ensure is set to Absent, all subfeatures will be uninstalled. | | | Credential | Write | System.Management.Automation.PSCredential | The credential of the user account under which to install or uninstall the roles or features. | | | LogPath | Write | System.String | The custom file path to which to log this operation. If not passed in, the default log path will be used (%WINDIR%\logs\ServerManager.log). | |

Description

Provides a mechanism to configure and manage multiple xWindowsFeature resources on a target node.

Requirements

  • Target machine must be running Windows Server 2008 or later.
  • Target machine must have access to the DISM PowerShell module.
  • Target machine must have access to the ServerManager module.

Examples

Example 1

#Requires -Module xPSDesiredStateConfiguration

<#
    .DESCRIPTION
        Configuration that adds several roles or features. The roles of features
        will be installed using all sub-features, and logs the operation to the
        file at 'C:\LogPath\Log.log'.

    .PARAMETER Name
        One or more names of the roles or features that you want to ensure is
        added.
        This is the same as the Name parameter from the Get-WindowsFeature
        cmdlet, and not the display name of the role or feature.

    .EXAMPLE
        xWindowsFeatureSet_AddFeatures_Config -Name @('Telnet-Client', 'RSAT-File-Services')

        Compiles a configuration that installs the Telnet-Client and
        RSAT-File-Services Windows features, including all their sub-features.
        Logs the operation to the file at 'C:\LogPath\Log.log'.

    .EXAMPLE
        Start-AzureRmAutomationDscCompilationJob -ResourceGroupName '<resource-group>' -AutomationAccountName '<automation-account>' -ConfigurationName 'xWindowsFeatureSet_AddFeaturesConfig' -Parameters @{ Name = @('Telnet-Client', 'RSAT-File-Services') }

        Compiles a configuration in Azure Automation that installs the
        Telnet-Client and RSAT-File-Services Windows features, including all
        their sub-features. Logs the operation to the file at 'C:\LogPath\Log.log'.

        Replace the <resource-group> and <automation-account> with correct values.
#>
Configuration xWindowsFeatureSet_AddFeatures_Config
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String[]]
        $Name
    )

    Import-DscResource -ModuleName xPSDesiredStateConfiguration

    Node localhost
    {
        xWindowsFeatureSet AddFeatures
        {
            Name                 = $Name
            Ensure               = 'Present'
            IncludeAllSubFeature = $true
            LogPath              = 'C:\LogPath\Log.log'
        }
    }
}

Example 2

#Requires -Module xPSDesiredStateConfiguration

<#
    .DESCRIPTION
        Configuration that removes several roles or features. The roles of features
        will be uninstalled together with all the sub-features, and logs the
        operation to the file at 'C:\LogPath\Log.log'.

    .PARAMETER Name
        One or more names of the roles or features that you want to ensure is
        removed.
        This is the same as the Name parameter from the Get-WindowsFeature
        cmdlet, and not the display name of the role or feature.

    .EXAMPLE
        xWindowsFeatureSet_RemoveFeatures_Config -Name @('Telnet-Client', 'RSAT-File-Services')

        Compiles a configuration that uninstalls the Telnet-Client and
        RSAT-File-Services Windows features, including all their sub-features.
        Logs the operation to the file at 'C:\LogPath\Log.log'.

    .EXAMPLE
        Start-AzureRmAutomationDscCompilationJob -ResourceGroupName '<resource-group>' -AutomationAccountName '<automation-account>' -ConfigurationName 'xWindowsFeatureSet_RemoveFeaturesConfig' -Parameters @{ Name = @('Telnet-Client', 'RSAT-File-Services') }

        Compiles a configuration in Azure Automation that uninstalls the
        Telnet-Client and RSAT-File-Services Windows features, including all
        their sub-features. Logs the operation to the file at 'C:\LogPath\Log.log'.

        Replace the <resource-group> and <automation-account> with correct values.
#>
Configuration xWindowsFeatureSet_RemoveFeatures_Config
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String[]]
        $Name
    )

    Import-DscResource -ModuleName xPSDesiredStateConfiguration

    Node localhost
    {
        xWindowsFeatureSet RemoveFeatures
        {
            Name                 = $Name
            Ensure               = 'Absent'
            IncludeAllSubFeature = $true
            LogPath              = 'C:\LogPath\Log.log'
        }
    }
}