Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.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
60
61
62
<#
    .EXAMPLE
        This example will make sure that the endpoint DefaultMirrorEndpoint is in started state in the default instance, if not it will start the endpoint.
 
    .EXAMPLE
        This example will make sure that the endpoint HADR is in started state in the default instance, if not it will start the endpoint.
 
    .EXAMPLE
        This example will make sure that the endpoint DefaultMirrorEndpoint is in started state in the named instance INSTANCE1, if not it will start the endpoint.
 
    .NOTES
        There is three different scenarios in this example to validate the schema during unit testing.
#>

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.Management.Automation.PSCredential]
        [System.Management.Automation.Credential()]
        $SysAdminAccount
    )

    Import-DscResource -ModuleName xSQLServer

    node localhost
    {
        # Start the DefaultMirrorEndpoint in the default instance
        xSQLServerEndpointState StartEndpoint1
        {
            NodeName             = 'SQLNODE01.company.local'
            InstanceName         = 'MSSQLSERVER'
            Name                 = 'DefaultMirrorEndpoint'
            State                = 'Started'

            PsDscRunAsCredential = $SysAdminAccount
        }

        # Start the HADR in the default instance
        xSQLServerEndpointState StartEndpoint2
        {
            NodeName             = 'SQLNODE01.company.local'
            InstanceName         = 'MSSQLSERVER'
            Name                 = 'HADR'
            State                = 'Started'

            PsDscRunAsCredential = $SysAdminAccount
        }

        # Start the DefaultMirrorEndpoint in the named instance INSTANCE1
        xSQLServerEndpointState StartEndpoint3
        {
            NodeName             = 'SQLNODE01.company.local'
            InstanceName         = 'INSTANCE1'
            Name                 = 'DefaultMirrorEndpoint'
            State                = 'Started'

            PsDscRunAsCredential = $SysAdminAccount
        }
    }
}