次の方法で共有


Enable-SqlAlwaysOn

Enables the Always On Availability Groups feature.

構文

ByPath (既定)

Enable-SqlAlwaysOn
    [[-Path] <String>]
    [-NoServiceRestart]
    [-Force]
    [-Credential <PSCredential>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByObject

Enable-SqlAlwaysOn
    [-InputObject] <Server>
    [-NoServiceRestart]
    [-Force]
    [-Credential <PSCredential>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByName

Enable-SqlAlwaysOn
    -ServerInstance <String>
    [-NoServiceRestart]
    [-Force]
    [-Credential <PSCredential>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

説明

The Enable-SqlAlwaysOn cmdlet enables Always On on an instance of SQL Server.

If the Always On Availability Groups feature is enabled while the SQL Server service is running, the database engine service must be restarted for the changes to complete.

Unless you specify the Force parameter, the cmdlet prompts you to restart the service.

If the Always On Availability Groups feature is already enabled, no action is performed.

This cmdlet can run against a remote service.

You must have Administrator permissions to execute this cmdlet.

Module requirements: version 21+ on PowerShell 5.1; version 22+ on PowerShell 7.x.

Example 1: Enable Always On Availability Groups at the specified path

PS C:\> Enable-SqlAlwaysOn -Path "SQLSERVER:\Sql\Computer\Instance"

This command enables Always On Availability Groups on the instance of SQL Server located at the specified path. This change requires restarting the instance, and you will be prompted to confirm this restart.

Example 2: Enable Always On Availability Groups at the specified path and restart the server without confirmation

PS C:\> Enable-SqlAlwaysOn -Path "SQLSERVER:\Sql\Computer\Instance" -Force

This command enables Always On Availability Groups on the instance of SQL Server located at the specified path. The Force option causes the server instance to be restarted without prompting you for confirmation.

Example 3: Enable Always On Availability Groups for the specified server instance

PS C:\> Enable-SqlAlwaysOn -ServerInstance "Computer\Instance"

This command enables Always On Availability Groups on the instance of SQL Server named Computer\Instance. This change requires restarting the instance and you will be prompted to confirm this restart.

Example 4: Enable Always On Availability Groups for the specified server instance using Windows authentication

PS C:\> Enable-SqlAlwaysOn -ServerInstance "Computer\Instance" -Credential (Get-Credential "DOMAIN\Username")

This command enables Always On Availability Groups on the instance of SQL Server named 'Computer\Instance' using Windows authentication. You will be prompted to enter the password for the specified account. This change requires restarting the instance, and you will also be prompted to confirm this restart.

Example 5: Enable Always On Availability Groups at the specified path without restarting the server

PS C:\> Enable-SqlAlwaysOn -Path "SQLSERVER:\Sql\Computer\Instance" -NoServiceRestart

This command enables Always On Availability Groups on the SQL Server instance located at the specified path, but the command does not restart the instance. The change will not take effect until you manually restart this server instance.

パラメーター

-Confirm

Prompts you for confirmation before running the cmdlet.

パラメーターのプロパティ

型:SwitchParameter
規定値:False
ワイルドカードのサポート:False
DontShow:False
Aliases:cf

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Credential

Specifies the name of the SQL Server instance on which to enable the Always On Availability Groups feature. The format is MACHINENAME\INSTANCE. To enable this setting on a remote server, use this along with the Credential parameter.

パラメーターのプロパティ

型:PSCredential
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Force

Forces the command to run without asking for user confirmation. This parameter is provided to permit the construction of scripts.

パラメーターのプロパティ

型:SwitchParameter
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-InputObject

Specifies the server object of the SQL Server instance.

パラメーターのプロパティ

型:Server
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByObject
配置:1
必須:True
パイプラインからの値:True
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-NoServiceRestart

Indicates that the user is not prompted to restart the SQL Server service. You must manually restart the SQL Server service for changes to take effect. When this parameter is set, Force is ignored.

パラメーターのプロパティ

型:SwitchParameter
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Path

Specifies the path to the SQL Server instance. This is an optional parameter. If not specified, the current working location is used.

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByPath
配置:1
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-ServerInstance

Specifies the name of the SQL Server instance. The format is MACHINENAME\INSTANCE. To enable this setting on a remote server, use this along with the Credential parameter.

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByName
配置:Named
必須:True
パイプラインからの値:False
プロパティ名別のパイプラインからの値:True
残りの引数からの値:False

-WhatIf

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

パラメーターのプロパティ

型:SwitchParameter
規定値:False
ワイルドカードのサポート:False
DontShow:False
Aliases:wi

パラメーター セット

(All)
配置: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

System.String

出力

System.Object