DSCResources/XD7LabStorefrontWebConfig/XD7LabStorefrontWebConfig.schema.psm1

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
configuration XD7LabStorefrontWebConfig {
<#
    .SYNOPSIS
        Configures a Xml element attribute
#>

    param (
        ## Path the Citrix Storefront web.config file
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [System.String] $Path,

        ## Enable or disable autolaunching of the default desktop
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $AutoLaunchDesktop,

        ## Enable or disable the desktop view
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $ShowDesktopsView,

        ## Enable or disable the applications view
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $ShowAppsView,

        ## Configure the default view
        [Parameter()]
        [ValidateSet('Auto','Apps','Desktops')]
        [System.String] $DefaultView,

        ## Determine whether Citrix Receiver is installed on the user's device
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $PluginAssistant,

        ## Determine whether an older Citrix Receiver is upgraded on the user's device
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $PluginAssistantUpgrade,

        ## Enable or disable Workspace control
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $WorkspaceControl,

        ## Enable or disable automatic reconnection to any applications left running
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $AutoReconnectAtLogon,

        ## Configure the default log off action
        [Parameter()]
        [ValidateSet('Disconnect','None','Terminate')]
        [System.String] $LogOffAction,

        # Enables or disables users' ability to manually reconnect to applications that they left running
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $ShowReconnectButton,

        # Enables or disables users' ability to manually disconnect from applications without shutting them down
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $ShowDisconnectButton,

        # Configures HTML5 Web Receiver to use same browser tab
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $SingleTabLaunch,

        ## Configures the Web Receiver session timeout (mins)
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.UInt16] $SessionTimeout
    )

    Import-DscResource -ModuleName PSDesiredStateConfiguration;

    $settings = @{
        AutoLaunchDesktop = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface';
                Attribute = 'autoLaunchDesktop';
            }
        ShowDesktopsView = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/uiViews';
                Attribute = 'showDesktopsView';
            }
        ShowAppsView = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/uiViews';
                Attribute = 'showAppsView';
            }
        DefaultView = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/uiViews';
                Attribute = 'defaultView';
            }
        PluginAssistant = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/pluginAssistant';
                Attribute = 'enabled';
            }
        PluginAssistantUpgrade = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/pluginAssistant';
                Attribute = 'upgradeAtLogin';
            }
        WorkspaceControl = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/workspaceControl';
                Attribute = 'enabled';
            }
        AutoReconnectAtLogon = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/workspaceControl';
                Attribute = 'autoReconnectAtLogon';
            }
        LogOffAction = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/workspaceControl';
                Attribute = 'logOffAction';
            }
        ShowReconnectButton = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/workspaceControl';
                Attribute = 'showReconnectButton';
            }
        ShowDisconnectButton = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/userInterface/workspaceControl';
                Attribute = 'showDisconnectButton';
            }
        SingleTabLaunch = @{
                XPath = '/configuration/citrix.deliveryservices/webReceiver/clientSettings/pluginAssistant/html5';
                Attribute = 'singleTabLaunch';
            }
        SessionTimeout = @{
                XPath = '/configuration/system.web/sessionState';
                Attribute = 'timeout';
            }
    }

    foreach ($settingsKey in $settings.Keys) {

        if ($PSBoundParameters.ContainsKey($settingsKey)) {

            $xpath = $settings[$settingsKey].XPath;
            $attributeName = $settings[$settingsKey].Attribute;
            $attributeValue = $PSBoundParameters[$settingsKey].ToString().ToLower();

            Script $settingsKey {

                GetScript = {

                    $xml = New-Object -TypeName 'System.Xml.XmlDocument';
                    $xml.Load($using:Path);
                    $node = $xml.SelectSingleNode($using:xpath);
                    return @{
                        Result = $node.$using:attributeName;
                    }

                }

                TestScript = {

                    $xml = New-Object -TypeName 'System.Xml.XmlDocument';
                    $xml.Load($using:Path);
                    $node = $xml.SelectSingleNode($using:xpath);
                    if ($node.$using:attributeName -ne $using:attributeValue) {
                        return $false;
                    }
                    else {
                        return $true;
                    }

                }

                SetScript = {

                    $xml = New-Object -TypeName 'System.Xml.XmlDocument';
                    $xml.Load($using:Path);
                    $node = $xml.SelectSingleNode($using:xpath);
                    $node.$using:attributeName = $using:attributeValue;
                    $xml.Save($using:Path);

                }
            } #end script
        }
    } #end foreach setting

} #end configuration XD7LabStorefrontWebConfig