Add-SqlAvailabilityGroupListenerStaticIp

Adds a static IP address to an existing availability group listener configuration.
Add-SqlAvailabilityGroupListenerStaticIp [-InputObject*] <AvailabilityGroupListener> -StaticIp* <string[]> [-Script][<CommonParameters>]
Add-SqlAvailabilityGroupListenerStaticIp [[-Path] <string>] -StaticIp* <string[]> [-Script] [<CommonParameters>]

The Add-SqlAvailabilityGroupListenerStaticIp cmdlet adds a static IP address to an existing availability group listener configuration. Takes the AvailabilityGroupListener, the path, and the static IP address as parameters. The IP address can be an IPv4 address with subnet or an IPv6 address. 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 AvailabilityGroupListener object of the listener to which you are adding the IP addresses.

-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.

-Script [<SwitchParameter>]

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

-StaticIp <string[]>

  • This value is required

The static IP addresses to be added to the availability group listener. This argument should be a list of strings. Each string can be either an IPv4 address and subnet mask in slash notation (for example, 192.168.1.1/255.255.255.0) or an IPv6 address.

<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 example adds a static IPv4 address to the availability group listener ‘MyListener’ on the availability group ‘MyAg’:
    C:PS> $path = "SQLSERVER:SQLPrimaryServerInstanceNameAvailabilityGroupsMyAgAvailabilityGroupListenersMyListener"
    Add-SqlAvailabilityGroupListenerStaticIp -Path $path -StaticIp "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
    

    This IPv4 address serves as the virtual IP address of the listener on the subnet 255.255.252.0. If the availability group spans multiple subnets, you should add a static IP address for each subnet to the listener. Add-SqlAvailabilityGroupListenerStaticIp commands must be executed on the server instance that hosts the primary replica.

  2. This command adds a static IPv6 address to the listener ‘MyListener’ on the availability group ‘MyAg’:
    C:PS> $path = "SQLSERVER:SQLPrimaryServerInstanceNameAvailabilityGroupsMyAgAvailabilityGroupListenersMyListener"
    Add-SqlAvailabilityGroupListenerStaticIp -Path $path -StaticIp "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
    
  3. This command outputs a Transact-SQL script that adds a static IPv4 address to the listener ‘MyListener’ on the availability group ‘MyAg’:
    C:PS> $path = "SQLSERVER:SQLPrimaryServerInstanceNameAvailabilityGroupsMyAgAvailabilityGroupListenersMyListener"
    Add-SqlAvailabilityGroupListenerStaticIp -Path $path -StaticIp "192.168.0.1/255.255.255.0" -Script
    
Additional Notes
 
Related Links