Skip to content
johlju edited this page Jun 9, 2020 · 1 revision

SqlServerEndpoint

Parameters

Parameter Attribute DataType Description Allowed Values
EndpointName Key String The name of the endpoint.
InstanceName Key String The name of the SQL instance to be configured.
EndpointType Required String Specifies the type of endpoint. Currently the only type that is supported is the Database Mirror type. DatabaseMirroring
Ensure Write String If the endpoint should be present or absent. Default values is 'Present'. Present, Absent
Port Write UInt16 The network port the endpoint is listening on. Default value is 5022, but default value is only used during endpoint creation, it is not enforce.
ServerName Write String The host name of the SQL Server to be configured. Default value is $env:COMPUTERNAME.
IpAddress Write String The network IP address the endpoint is listening on. Default the endpoint will listen on any valid IP address. The default value is only used during endpoint creation, it is not enforce.
Owner Write String The owner of the endpoint. Default is the login used for the creation.
State Write String Specifies the state of the endpoint. Valid states are Started, Stopped, or Disabled. When an endpoint is created and the state is not specified then the endpoint will be started after it is created. The state will not be enforced unless the parameter is specified. Started, Stopped, Disabled

Description

The SqlEndpoint DSC resource is used to create an endpoint. Currently it only supports creating a database mirror endpoint which can be used by, for example, AlwaysOn.

Note: The endpoint will be started after creation, but will not be enforced unless the the parameter State is specified. To set connect permission to the endpoint, please use the resource SqlEndpointPermission.

Requirements

  • Target machine must be running Windows Server 2012 or later.
  • Target machine must be running SQL Server Database Engine 2012 or later.

Security Requirements

  • The built-in parameter PsDscRunAsCredential must be set to the credentials of an account with the permission to create and alter endpoints.

Known issues

All issues are not listed here, see here for all open issues.

Examples

Example 1

This example will add a Database Mirror endpoint, to two instances, using the default values.

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

    Import-DscResource -ModuleName 'SqlServerDsc'

    node localhost
    {
        SqlServerEndpoint 'SQLConfigureEndpoint-Instance1'
        {
            EndpointName         = 'HADR'
            EndpointType         = 'DatabaseMirroring'
            InstanceName         = 'INST1'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }

        SqlServerEndpoint 'SQLConfigureEndpoint-Instances2'
        {
            EndpointName         = 'HADR'
            EndpointType         = 'DatabaseMirroring'
            InstanceName         = 'INST2'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }
    }
}

Example 2

This example will add a Database Mirror endpoint with specific listener port, listener IP address and owner.

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

    Import-DscResource -ModuleName 'SqlServerDsc'

    node localhost
    {
        SqlServerEndpoint 'SQLConfigureEndpoint'
        {
            Ensure               = 'Present'

            EndpointName         = 'HADR'
            EndpointType         = 'DatabaseMirroring'
            Port                 = 9001
            IpAddress            = '192.168.0.20'
            Owner                = 'sa'
            State                = 'Started'

            ServerName           = 'server1.company.local'
            InstanceName         = 'INST1'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }
    }
}

Example 3

This example will remove an Database Mirror endpoint from two instances.

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

    Import-DscResource -ModuleName 'SqlServerDsc'

    node localhost
    {
        SqlServerEndpoint 'SQLConfigureEndpoint-Instance1'
        {
            Ensure               = 'Absent'

            EndpointName         = 'HADR'
            EndpointType         = 'DatabaseMirroring'
            InstanceName         = 'INST1'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }

        SqlServerEndpoint 'SQLConfigureEndpoint-Instance2'
        {
            Ensure               = 'Absent'

            EndpointName         = 'HADR'
            EndpointType         = 'DatabaseMirroring'
            InstanceName         = 'INST2'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }
    }
}
Clone this wiki locally