Join-SqlAvailabilityGroup

Joins the local secondary replica to an availability group.

语法

ByPath (默认值)

Join-SqlAvailabilityGroup
    [-Name] <String>
    [[-Path] <String>]
    [-Script]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByObject

Join-SqlAvailabilityGroup
    [-Name] <String>
    [-InputObject] <Server>
    [-Script]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

The Join-SqlAvailabilityGroup cmdlet joins the local secondary replica to an availability group. Run this cmdlet on an instance of SQL Server that hosts a secondary replica that is not joined to the availability group.

示例

Example 1: Join a secondary replica to an availability group

PS C:\> Join-SqlAvailabilityGroup -Path "SQLSERVER:\SQL\SecondaryServer\InstanceName" -Name "MainAG"

This command joins a secondary replica to the availability group named MainAG. This server instance must host a secondary replica in this availability group.

Example 2: Create a script that joins a secondary replica to an availability group

PS C:\> Join-SqlAvailabilityGroup -Path "SQLSERVER:\SQL\SecondaryServer\InstanceName" -Name "MainAG" -Script

This command creates a Transact-SQL script that joins a secondary replica to the availability group named MainAG.

参数

-Confirm

Prompts you for confirmation before running the cmdlet.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

Specifies the server that hosts the instance of SQL Server that hosts the secondary replica that this cmdlet joins to the availability group.

参数属性

类型:Server
默认值:None
支持通配符:False
不显示:False

参数集

ByObject
Position:3
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Name

Specifies the name of the availability group to which this cmdlet joins a secondary replica.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Path

Specifies the path of the instance of SQL Server that hosts the secondary replica that this cmdlet joins to the availability group. If you do not specify this parameter, this cmdlet uses current working location.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByPath
Position:3
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Script

Indicates that this cmdlet returns a Transact-SQL script that performs the task that this cmdlet performs.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:wi

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

Microsoft.SqlServer.Management.Smo.Server

You can pass a server instance to this cmdlet.

备注

  • The high availability data recovery service must be enabled on the server instance. The availability replica specified by the Path parameter must exist.