Examples/Resources/SPDistributedCacheService/3-MultiServerCache.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
47
48
49
50
51
52
53
54
55
56
57
58
59
<#
.EXAMPLE
    This example applies the distributed cache service to both "server1" and
    "server2". The ServerProvisionOrder will ensure that it applies it to
    server1 first and then server2, making sure they don't both attempt to
    create the cache at the same time, resuling in errors.
 
    Note: Do not allow plain text passwords in production environments.
#>


    $ConfigurationData = @{
        AllNodes = @(
            @{
                NodeName = 'Server1'
                PSDscAllowPlainTextPassword = $true
            },
            @{
                NodeName = 'Server2'
                PSDscAllowPlainTextPassword = $true
            }
        )
    }

    Configuration Example 
    {
        param(
            [Parameter(Mandatory = $true)]
            [PSCredential]
            $SetupAccount
        )
        Import-DscResource -ModuleName SharePointDsc
        
        node "Server1" 
        {
            SPDistributedCacheService EnableDistributedCache
            {
                Name                 = "AppFabricCachingService"
                CacheSizeInMB        = 8192
                ServiceAccount       = "DEMO\ServiceAccount"
                ServerProvisionOrder = @("Server1","Server2")
                CreateFirewallRules  = $true
                InstallAccount       = $SetupAccount
            }
        }

        node "Server2"
        {
            SPDistributedCacheService EnableDistributedCache
            {
                Name                 = "AppFabricCachingService"
                CacheSizeInMB        = 8192
                ServiceAccount       = "DEMO\ServiceAccount"
                ServerProvisionOrder = @("Server1","Server2")
                CreateFirewallRules  = $true
                InstallAccount       = $SetupAccount
            }
        }
    }