Examples/Sample_xWindowsFeature.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<#
    Create a custom configuration by passing in whatever values you need.
    $Name is the only parameter that is required which indicates which
    Windows Feature you want to install (or uninstall if you set Ensure to Absent).
    LogPath and Credential are not included here, but if you would like to specify
    a custom log path or need a credential just pass in the desired values and add
    LogPath = $LogPath and/or Credential = $Credential to the configuration here
#>
      

Configuration 'Install_Feature_Telnet_Client'
{
    param 
    (       
        [System.String]
        $Name = 'Telnet-Client',

        [ValidateSet('Present', 'Absent')]
        [System.String]
        $Ensure = 'Present',

        [System.Boolean]
        $IncludeAllSubFeature = $false,

        [System.Management.Automation.PSCredential]
        [System.Management.Automation.Credential()]
        $Credential,

        [ValidateNotNullOrEmpty()]
        [System.String]
        $LogPath
    )
    
    Import-DscResource -ModuleName 'xPSDesiredStateConfiguration'
    
    Node Localhost {

        xWindowsFeature WindowsFeatureTest
        {
            Name = $Name
            Ensure = $Ensure
            IncludeAllSubFeature = $IncludeAllSubFeature
        }
    }
}