< Back
Add-DbaAgListener
Post
NAME Add-DbaAgListener
SYNOPSIS
Adds a listener to an availability group on a SQL Server instance.
SYNTAX
Add-DbaAgListener [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]
<Pscredential>] [[-AvailabilityGroup] <System.String[]>] [[-Name] <String>] [[-IPAddress]
<System.Net.IPAddress[]>] [[-SubnetIP] <System.Net.IPAddress[]>] [[-SubnetMask] <System.Net.IPAddress[]>] [[-Port]
<Int>] [-Dhcp <Switch>] [-Passthru <Switch>] [[-InputObject]
<Microsoft.SqlServer.Management.Smo.AvailabilityGroup[]>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Adds a listener to an availability group on a SQL Server instance.
PARAMETERS
-AvailabilityGroup [<System.String[]>]
The Availability Group to which a listener will be bestowed upon.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Dhcp [<Switch>]
Indicates whether the listener uses DHCP.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-InputObject [<Microsoft.SqlServer.Management.Smo.AvailabilityGroup[]>]
Enables piping from Get-DbaAvailabilityGroup
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-IPAddress [<System.Net.IPAddress[]>]
Sets the IP address(es) of the availability group listener.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Name [<String>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Passthru [<Switch>]
Don't create the listener, just pass thru an object that can be further customized before creation.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Port [<Int>]
Sets the port number used to communicate with the availability group. Defaults to 1433.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported.
Accepts credential objects (Get-Credential)
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SubnetIP [<System.Net.IPAddress[]>]
Sets the Subnet IP address(es) of the availability group listener.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SubnetMask [<System.Net.IPAddress[]>]
Sets the subnet IP mask(s) of the availability group listener. Defaults to 255.255.255.0.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: AvailabilityGroup, HA, AG
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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.
RELATED LINKS
https://dbatools.io/Add-DbaAgListener
SYNOPSIS
Adds a listener to an availability group on a SQL Server instance.
SYNTAX
Add-DbaAgListener [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]
<Pscredential>] [[-AvailabilityGroup] <System.String[]>] [[-Name] <String>] [[-IPAddress]
<System.Net.IPAddress[]>] [[-SubnetIP] <System.Net.IPAddress[]>] [[-SubnetMask] <System.Net.IPAddress[]>] [[-Port]
<Int>] [-Dhcp <Switch>] [-Passthru <Switch>] [[-InputObject]
<Microsoft.SqlServer.Management.Smo.AvailabilityGroup[]>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Adds a listener to an availability group on a SQL Server instance.
PARAMETERS
-AvailabilityGroup [<System.String[]>]
The Availability Group to which a listener will be bestowed upon.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Dhcp [<Switch>]
Indicates whether the listener uses DHCP.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-InputObject [<Microsoft.SqlServer.Management.Smo.AvailabilityGroup[]>]
Enables piping from Get-DbaAvailabilityGroup
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-IPAddress [<System.Net.IPAddress[]>]
Sets the IP address(es) of the availability group listener.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Name [<String>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Passthru [<Switch>]
Don't create the listener, just pass thru an object that can be further customized before creation.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Port [<Int>]
Sets the port number used to communicate with the availability group. Defaults to 1433.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported.
Accepts credential objects (Get-Credential)
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SubnetIP [<System.Net.IPAddress[]>]
Sets the Subnet IP address(es) of the availability group listener.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SubnetMask [<System.Net.IPAddress[]>]
Sets the subnet IP mask(s) of the availability group listener. Defaults to 255.255.255.0.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: AvailabilityGroup, HA, AG
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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.
RELATED LINKS
https://dbatools.io/Add-DbaAgListener