Skip to content

SqlEndpoint

dscbot edited this page Aug 13, 2024 · 13 revisions

SqlEndpoint

Parameters

Parameter Attribute DataType Description Allowed Values
EndpointName Key String The name of the endpoint.
InstanceName Key String The name of the SQL Server instance to be configured.
EndpointType Required String Specifies the type of endpoint. Currently the only types that are supported are the Database Mirroring and the Service Broker type. DatabaseMirroring, ServiceBroker
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 the current computer name.
IpAddress Write String The network IP address the endpoint is listening on. Default value is '0.0.0.0' which means 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.
IsMessageForwardingEnabled Write Boolean Specifies whether messages received by this endpoint that are for services located elsewhere will be forwarded.
MessageForwardingSize Write UInt32 Specifies the maximum amount of storage in megabytes to allocate for the endpoint to use when storing messages that are to be forwarded.
State Write String Specifies the state of the endpoint. 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 and a service broker endpoint. A database mirror endpoint can be used by AlwaysOn.

Important

The endpoint will be started after creation, but will not be enforced unless the the parameter State is specified.

[!TIP] 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
    {
        SqlEndpoint 'SQLConfigureEndpoint-Instance1'
        {
            EndpointName         = 'HADR'
            EndpointType         = 'DatabaseMirroring'
            InstanceName         = 'INST1'

            PsDscRunAsCredential = $SqlAdministratorCredential
        }

        SqlEndpoint '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
    {
        SqlEndpoint '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 add a Service Broker endpoint, to a instance, complete with MessageForwarding

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

    Import-DscResource -ModuleName 'SqlServerDsc'

    node localhost
    {
        SqlEndpoint 'ServiceBroker'
        {
            Ensure                     = 'Present'

            EndpointName               = 'SSBR'
            EndpointType               = 'ServiceBroker'
            Port                       = 5023
            IpAddress                  = '192.168.0.20'
            Owner                      = 'sa'
            State                      = 'Started'

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

            IsMessageForwardingEnabled = $true
            MessageForwardingSize      = 2

            PsDscRunAsCredential       = $SqlAdministratorCredential
        }
    }
}

Example 4

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
    {
        SqlEndpoint 'SQLConfigureEndpoint-Instance1'
        {
            Ensure               = 'Absent'

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

            PsDscRunAsCredential = $SqlAdministratorCredential
        }

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

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

            PsDscRunAsCredential = $SqlAdministratorCredential
        }
    }
}

Home

General

Commands

Clone this wiki locally