DSCResources/XD7LabMsiLicenseServer/XD7LabMsiLicenseServerschema.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
configuration XD7LabMsiLicenseServer {
    [CmdletBinding()]
    param (
        ## Citrix XenDesktop installation source root
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [System.String] $MsiPath,

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

        ## Path Citrix XenDesktop license file(s)
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [System.String[]] $CitrixLicensePath,

        ## Active Directory domain account used to download the Citrix license file(s)
        [Parameter()]
        [ValidateNotNull()]
        [System.Management.Automation.PSCredential]
        [System.Management.Automation.CredentialAttribute()]
        $Credential,

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

    Import-DscResource -ModuleName XenDesktop7, PSDesiredStateConfiguration;

    if ($InstallRDSLicensingRole) {

        WindowsFeature 'RDSLicensing' {
            Name = 'RDS-Licensing';
        }

        WindowsFeature 'RDSLicensingUI' {
            Name = 'RDS-Licensing-UI';
        }
    }

    Package 'CitrixLicenseServerMsi' {
        Name = 'Citrix Licensing';
        ProductId = ''
        Path = $MsiPath;
        Ensure = 'Present';
    }
    
    if ($IsCitrixLicensePathDirectory) {

        $fileType = 'Directory';
        $fileRecurse = $true;
    }
    else {

        $fileType = 'File';
        $fileRecurse = $false;
    }

    foreach ($licenseFile in $CitrixLicensePath) {

        $counter = 1;
        if ($PSBoundParameters.ContainsKey('Credential')) {

            File "XDLicenseFile_$counter" {
                Type = $fileType;
                Recurse = $fileRecurse;
                SourcePath = $licenseFile;
                DestinationPath = "${env:ProgramFiles(x86)}\Citrix\Licensing\MyFiles";
                Credential = $Credential;
            }
        }
        else {

            File "XDLicenseFile_$counter" {
                Type = $fileType;
                Recurse = $fileRecurse;
                SourcePath = $licenseFile;
                DestinationPath = "${env:ProgramFiles(x86)}\Citrix\Licensing\MyFiles";
            }
        }
        $counter++;
    }

} #end configuration XD7LabMsiLicenseServer