DSCResources/XD7LabSimple/XD7LabSimple.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
configuration XD7LabSimple {
     param (
        ## Citrix XenDesktop installation source root
        [Parameter(Mandatory)]
        [System.String] $XenDesktopMediaPath,

        ## Citrix XenDesktop site name
        [Parameter(Mandatory)]
        [System.String] $SiteName,

        ## Server fully-qualified domain name
        [Parameter(Mandatory)]
        [System.String] $ServerName,

        ## Database server fully-qualified domain name
        [Parameter(Mandatory)]
        [System.String] $DatabaseServerName,

        ## Local path to Citrix XenDesktop license file(s)
        [Parameter(Mandatory)]
        [System.String[]] $CitrixLicensePath,

        ## Domain FQDN
        [Parameter(Mandatory)]
        [System.String] $DomainName,

        ## Path to Citrix XenDesktop license file(s) are directory paths
        [Parameter()]
        [System.Boolean] $IsCitrixLicensePathDirectory,

        ## Custom StoreFront base url
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String] $StoreFrontBaseUrl,

        ## IIS root redirection relative/absolute url
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String] $StoreFrontRedirectUrl,

        ## Storefront explicit authentication methods available
        [Parameter()]
        [ValidateSet('IntegratedWindows','HttpBasic','ExplicitForms','CitrixFederation','CitrixAGBasic','Certificate')]
        [System.String[]] $StoreFrontAuthenticationMethods,

        ## Delivery group active directory user/groups
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String[]] $Users = 'Domain Users',

        ## Machine catalog name
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String] $CatalogName = 'Manual',

        ## Delivery group name
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String] $DeliveryGroupName = 'Default Desktop',

        ## Delivery group name
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String] $DeliveryGroupDescription = 'Virtual Engine XenDesktop Lab Desktop KEYWORDS:Auto',

        ## Citrix XenDesktop licensing model
        [Parameter()]
        [ValidateSet('UserDevice','Concurrent')]
        [System.String] $LicenseModel = 'UserDevice',

        ## Install Microsoft RDS license server role
        [Parameter()]
        [ValidateNotNull()]
        [System.Boolean] $InstallRDSLicensingRole = $true,

        ## Citrix XenDesktop full administrators
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String[]] $SiteAdministrator,

        ## The XML Broker Service trust settings
        [Parameter()]
        [ValidateNotNull()]
        [System.Boolean] $TrustRequestsSentToXmlServicePort,

        ## Enable or disable auto-launching of the default desktop
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $AutoLaunchDesktop = $true,

        ## Enable the Citrix Receiver plugin detection
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $StorefrontPluginAssistant = $true,

        ## Citrix Storefront session timeout (mins)
        [Parameter()]
        [ValidateNotNull()]
        [System.UInt16] $StorefrontSessionTimeout = 20,

        ## Enable the Citrix Storefront Unified Experience
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.Boolean] $StorefrontUnifiedExperience,

         ## Active Directory domain account used to install/configure the Citrix XenDesktop site
        [Parameter()]
        [ValidateNotNull()]
        [System.Management.Automation.PSCredential]
        [System.Management.Automation.CredentialAttribute()]
        $Credential
    )

    ## Avoid recursive import of the XenDesktop7Lab resource!
    Import-DscResource -Name XD7StoreFrontAuthenticationMethod, XD7StoreFrontReceiverAuthenticationMethod;
    Import-DscResource -Name XD7StoreFrontUnifiedExperience, XD7LabSessionHost, XD7LabStorefront;
    Import-DscResource -Name XD7LabLicenseServer, XD7LabSite, XD7LabMachineCatalog, XD7LabDeliveryGroup;
    Import-DscResource -Name XD7LabStorefrontUrl, XD7LabStorefrontRedirect, XD7LabStorefrontWebConfig;

    ## Create ServerName and ServerName.DomainName names
    if ($ServerName.Contains('.')) {
        $credSSPDelegatedComputers = @($ServerName, $ServerName.Split('.')[0]);
    }
    else {
        $credSSPDelegatedComputers = @($ServerName, ('{0}.{1}' -f $ServerName, $DomainName));
    }

    if (-not $DatabaseServerName.Contains('.')) {
        ## Create database server FQDN
        $DatabaseServerName = '{0}.{1}' -f $DatabaseServerName, $DomainName;
    }

    $domainUsers = @();
    foreach ($user in $Users) {

        if (($user.Contains('\')) -or ($user.Contains('@'))) {
            ## User group is already in domain format
            $domainUsers += $user;
        }
        else {
            ## Convert user/group to NetBIOSDomainName\Username
            $domainUsers += '{0}\{1}' -f $DomainName.Split('.')[0], $user;
        }
    }

    XD7LabSessionHost 'XD7SessionHost' {
        XenDesktopMediaPath = $XenDesktopMediaPath;
        ControllerAddress = $ServerName;
        RDSLicenseServer = $ServerName;
    }

    XD7LabStoreFront 'XD7StoreFront' {
        XenDesktopMediaPath = $XenDesktopMediaPath;
        ControllerAddress = $ServerName;
    }

    XD7LabLicenseServer 'XD7LicenseServer' {
        XenDesktopMediaPath = $XenDesktopMediaPath;
        InstallRDSLicensingRole = $InstallRDSLicensingRole;
        CitrixLicensePath = $CitrixLicensePath;
        IsCitrixLicensePathDirectory = $IsCitrixLicensePathDirectory;
    }

    if ($PSBoundParameters.ContainsKey('Credential')) {
        ## Ensure we have domain credentials
        if ((-not $Credential.UserName.Contains('@')) -or (-not($Credential.UserName.Contains('\')))) {
            $credentialUPN = '{0}@{1}' -f $Credential.UserName, $DomainName;
            $Credential = New-Object System.Management.Automation.PSCredential($credentialUPN, $Credential.Password);
        }

        if ($PSBoundParameters.ContainsKey('SiteAdministrator')) {
            
            XD7LabSite 'XD7Site' {
                XenDesktopMediaPath = $XenDesktopMediaPath;
                Credential = $Credential;
                SiteName = $SiteName;
                DatabaseServer = $DatabaseServerName;
                LicenseServer = $ServerName;
                SiteAdministrators = $SiteAdministrator;
                DelegatedComputers = $credSSPDelegatedComputers;
                LicenseModel = $LicenseModel;
                TrustRequestsSentToXmlServicePort = $TrustRequestsSentToXmlServicePort;
            }

        }
        else {

            XD7LabSite 'XD7Site' {
                XenDesktopMediaPath = $XenDesktopMediaPath;
                Credential = $Credential;
                SiteName = $SiteName;
                DatabaseServer = $DatabaseServerName;
                LicenseServer = $ServerName;
                DelegatedComputers = $credSSPDelegatedComputers;
                LicenseModel = $LicenseModel;
                TrustRequestsSentToXmlServicePort = $TrustRequestsSentToXmlServicePort;
            }

        }

        XD7LabMachineCatalog 'XD7Catalog' {
            Name = $CatalogName;
            Credential = $Credential;
            ComputerName = $ServerName;
            DependsOn = '[XD7LabSite]XD7Site';
        }

        XD7LabDeliveryGroup 'XD7DeliveryGroup' {
            Name = $DeliveryGroupName;
            Credential = $Credential;
            ComputerName = $ServerName;
            Description = $DeliveryGroupDescription;
            Users = $domainUsers;
            DependsOn = '[XD7LabMachineCatalog]XD7Catalog';
        }
    }
    else {

        if ($PSBoundParameters.ContainsKey('SiteAdministrator')) {
            
            XD7LabSite 'XD7Site' {
                XenDesktopMediaPath = $XenDesktopMediaPath;
                SiteName = $SiteName;
                DatabaseServer = $DatabaseServerName;
                LicenseServer = $ServerName;
                SiteAdministrators = $SiteAdministrator;
                DelegatedComputers = $credSSPDelegatedComputers;
                LicenseModel = $LicenseModel;
                TrustRequestsSentToXmlServicePort = $TrustRequestsSentToXmlServicePort;
            }

        }
        else {

            XD7LabSite 'XD7Site' {
                XenDesktopMediaPath = $XenDesktopMediaPath;
                SiteName = $SiteName;
                DatabaseServer = $DatabaseServerName;
                LicenseServer = $ServerName;
                DelegatedComputers = $credSSPDelegatedComputers;
                LicenseModel = $LicenseModel;
                TrustRequestsSentToXmlServicePort = $TrustRequestsSentToXmlServicePort;
            }

        }

        XD7LabMachineCatalog 'XD7Catalog' {
            Name = $CatalogName;
            ComputerName = $ServerName;
            DependsOn = '[XD7LabSite]XD7Site';
        }

        XD7LabDeliveryGroup XD7DeliveryGroup {
            Name = $DeliveryGroupName;
            ComputerName = $ServerName;
            Description = $DeliveryGroupDescription;
            Users = $domainUsers;
            DependsOn = '[XD7LabMachineCatalog]XD7Catalog';
        }
    }

    if ($PSBoundParameters.ContainsKey('StoreFrontAuthenticationMethods')) {

        XD7StoreFrontAuthenticationMethod 'StoreAuthenticationMethod' {
            VirtualPath = '/Citrix/Authentication';
            AuthenticationMethod = $StoreFrontAuthenticationMethods;
            ## Installing the site, creates the Storefront Store
            DependsOn = '[XD7LabSite]XD7Site';
        }

        XD7StoreFrontReceiverAuthenticationMethod 'StorefrontAuthenticationMethod' {
            VirtualPath = '/Citrix/StoreWeb';
            AuthenticationMethod = $StoreFrontAuthenticationMethods;
            DependsOn = '[XD7StoreFrontAuthenticationMethod]StoreAuthenticationMethod';
        }
    } #end if StoreFrontAuthenticationMethods

    if (($PSBoundParameters.ContainsKey('AutoLaunchDesktop')) -or
        ($PSBoundParameters.ContainsKey('StorefrontPluginAssistant')) -or
        ($PSBoundParameters.ContainsKey('StorefrontSessionTimeout'))) {

        XD7LabStorefrontWebConfig 'XD7StorefrontWebConfig' {
            Path = 'C:\inetpub\wwwroot\Citrix\StoreWeb\web.config';
            AutoLaunchDesktop = $AutoLaunchDesktop;
            PluginAssistant = $StorefrontPluginAssistant;
            SessionTimeout = $StorefrontSessionTimeout;
            ## Installing the site, creates the Storefront Store
            DependsOn = '[XD7LabSite]XD7Site';
        }
    }

    if ($PSBoundParameters.ContainsKey('StorefrontBaseUrl')) {

        XD7LabStoreFrontUrl 'lab_simple_storefront' {
            BaseUrl = $StoreFrontBaseUrl;
        }

    } #end if Storefront Base Url

    if ($PSBoundParameters.ContainsKey('StorefrontRedirectUrl')) {

        XD7LabStoreFrontRedirect 'lab_simple_storefront_redirect' {
            RedirectUrl = $StoreFrontRedirectUrl;
        }

    } #end if Storefront Redirect Url

    if ($PSBoundParameters.ContainsKey('StorefrontUnifiedExperience')) {

        XD7StoreFrontUnifiedExperience 'StoreFrontUnifiedExperience' {
            VirtualPath = '/Citrix/Store';
            WebReceiverVirtualPath = '/Citrix/StoreWeb';
            Ensure = if (StorefrontUnifiedExperience -eq $true) { 'Present' } else { 'Absent' }
        }
    } #end if Storefront Unified Experience

} #end configuration XD7LabSimple