Set-SqlAvailabilityGroupListener

This cmdlet modifies the port setting on an existing availability group listener.
Set-SqlAvailabilityGroupListener [-InputObject*] <AvailabilityGroupListener> [-Port <int>] [-Script][<CommonParameters>]
Set-SqlAvailabilityGroupListener [[-Path] <string>] [-Port <int>] [-Script] [<CommonParameters>]

The Set-SqlAvailabilityGroupListener cmdlet modifies the port setting on an existing availability group listener. This cmdlet can be executed only at the server instance that hosts the primary replica.

Parameters
-InputObject <AvailabilityGroupListener>

  • This value is required
  • Accepts pipeline input ByValue

The SMO AvailabilityGroupListener object of the listener to be modified.

-Path <string>

The path to the availability group listener. This is an optional parameter. If not specified, the value of this parameter defaults to the current working location.

-Port <int>

  • Default value is 1433

The TCP port that the listener will use to listen for connections. The default port is TCP port 1433. If you have security concerns, we recommend using a different port number.

-Script [<SwitchParameter>]

Outputs a Transact-SQL script that performs the task executed by this cmdlet.

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.

Inputs

Microsoft.SqlServer.Management.Smo.AvailabilityGroupListener

Examples
  1. This command sets the port number for the availability group listener named ‘MyListener’ to 1535:
    C:PS> Set-SqlAvailabilityGroupListener -Port 1535 -Path SQLSERVER:SqlPrimaryServerInstanceNameAvailabilityGroupsMyAgAvailabilityGroupListenersMyListener
    

    This port is used to listen for connections to the listener.

  2. This command generates the Transact-SQL script that sets the port number for the availability group listener named ‘MyListener’ to 1535:
    C:PS> Set-SqlAvailabilityGroupListener -Port 1535 -Script -Path SQLSERVER:SqlPrimaryServerInstanceNameAvailabilityGroupsMyAgAvailabilityGroupListenersMyListener
    

    The port number is not actually changed by this command.

Additional Notes
 
Related Links