DSCResources/XD7LabMachineCatalog/XD7LabMachineCatalog.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
configuration XD7LabMachineCatalog {
    param (
        ## Machine catalog name
        [Parameter(Mandatory)]
        [System.String] $Name,

        ## Machine catalog computer accounts/members
        [Parameter(Mandatory)]
        [System.String[]] $ComputerName,

        ## Machine catalog allocation type (defaults to 'Random')
        [Parameter()]
        [ValidateSet('Permanent','Random','Static')]
        [System.String] $Allocation = 'Random',

        ## Machine catalog provisioning type (defaults to 'Manual')
        [Parameter()]
        [ValidateSet('Manual','PVS','MCS')]
        [System.String] $Provisioning = 'Manual',

        ## Machine catalog user persistence type (defaults to 'Local')
        [Parameter()]
        [ValidateSet('Discard','Local','PVD')]
        [System.String] $Persistence = 'Local',

        ## Machine catalog is RDS/Session Hosts
        [Parameter()]
        [ValidateNotNull()]
        [System.Boolean] $IsMultiSession = $true,

        ## Machine catalog description
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String] $Description = 'Manual machine catalog provisioned by DSC',

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

    Import-DscResource -ModuleName XenDesktop7;
    $resourceName = $Name.Replace(' ','_');

    ## Machine catalog members should not be FQDNs
    $catalogMembers = @();
    foreach ($member in $ComputerName) {

        if ($member.Contains('.')) {
            $catalogMembers += $member.Split('.')[0];
        }
        else {
            $catalogMembers += $member;
        }
    } #end foreach catalog member

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

        XD7Catalog "Catalog_$resourceName" {
            Name = $Name;
            Description = $Description;
            Allocation = $Allocation;
            Persistence = $Persistence;
            Provisioning = $Provisioning;
            IsMultiSession = $IsMultiSession;
            Credential = $Credential;
        }

        XD7CatalogMachine "Catalog_$($resourceName)_Machines" {
            Name = $Name;
            Members = $catalogMembers;
            Credential = $Credential;
            DependsOn = "[XD7Catalog]Catalog_$resourceName";
        }
    }
    else {

        XD7Catalog "Catalog_$resourceName" {
            Name = $Name;
            Description = $Description;
            Allocation = $Allocation;
            Persistence = $Persistence;
            Provisioning = $Provisioning;
            IsMultiSession = $IsMultiSession;
        }

        XD7CatalogMachine "Catalog_$($resourceName)_Machines" {
            Name = $Name;
            Members = $catalogMembers;
            DependsOn = "[XD7Catalog]Catalog_$resourceName";
        }
    }

} #end configuration XD7LabMachineCatalog