commands

^

Add-DbaAgListener

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Synopsis

Adds a listener to an availability group on a SQL Server instance.

Description

Adds a listener to an availability group on a SQL Server instance.

Syntax

Add-DbaAgListener
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-AvailabilityGroup] <String[]>]
    [[-Name] <String>]
    [[-IPAddress] <IPAddress[]>]
    [[-SubnetIP] <IPAddress[]>]
    [[-SubnetMask] <IPAddress[]>]
    [[-Port] <Int32>]
    [-Dhcp]
    [-Passthru]
    [[-InputObject] <AvailabilityGroup[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Add-DbaAgListener -SqlInstance sql2017 -AvailabilityGroup SharePoint -IPAddress 10.0.20.20

Creates a listener on 10.0.20.20 port 1433 for the SharePoint availability group on sql2017.

Example: 2
PS C:\> Get-DbaAvailabilityGroup -SqlInstance sql2017 -AvailabilityGroup availabilitygroup1 | Add-DbaAgListener -Dhcp

Creates a listener on port 1433 with a dynamic IP for the group1 availability group on sql2017.

Example: 3
PS C:\> Add-DbaAgListener -SqlInstance sql2017 -AvailabilityGroup SharePoint -IPAddress 10.0.20.20,10.1.77.77 -SubnetMask 255.255.252.0

Creates a multi-subnet listener with 10.0.20.20 and 10.1.77.77, on two /22 subnets, on port 1433 for the SharePoint availability group on sql2017.

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.

Alias
Required False
Pipeline false
Default Value
-SqlCredential

Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)

Alias
Required False
Pipeline false
Default Value
-AvailabilityGroup

The Availability Group to which a listener will be bestowed upon.

Alias
Required False
Pipeline false
Default Value
-Name

The name of the listener. If one is not specified, the Availability Group name will be used. Note that Name cannot be used with Multiple Ags.

Alias
Required False
Pipeline false
Default Value
-IPAddress

Sets the IP address(es) of the availability group listener.

Alias
Required False
Pipeline false
Default Value
-SubnetIP

Sets the Subnet IP address(es) of the availability group listener.

Alias
Required False
Pipeline false
Default Value
-SubnetMask

Sets the subnet IP mask(s) of the availability group listener. Defaults to 255.255.255.0.

Alias
Required False
Pipeline false
Default Value 255.255.255.0
-Port

Sets the port number used to communicate with the availability group. Defaults to 1433.

Alias
Required False
Pipeline false
Default Value 1433
-Dhcp

Indicates whether the listener uses DHCP.

Alias
Required False
Pipeline false
Default Value False
-Passthru

Don't create the listener, just pass thru an object that can be further customized before creation.

Alias
Required False
Pipeline false
Default Value False
-InputObject

Enables piping from Get-DbaAvailabilityGroup

Alias
Required False
Pipeline true (ByValue)
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value

 

Want to see the source code for this command? Check out Add-DbaAgListener on GitHub.
Want to see the Bill Of Health for this command? Check out Add-DbaAgListener.