Enable-SqlAlwaysOn
Enables the AlwaysOn Availability Groups feature on the instance of SQL Server specified by the Path, InputObject,or ServerInstance parameter.
Enable-SqlAlwaysOn [[-Path] <string>] [-Credential <PSCredential>] [-Force] [-NoServiceRestart] [-Confirm][-WhatIf] [<CommonParameters>]
Enable-SqlAlwaysOn -InputObject* <Server> [-Credential <PSCredential>] [-Force] [-NoServiceRestart] [-Confirm][-WhatIf] [<CommonParameters>]
Enable-SqlAlwaysOn [-ServerInstance*] <string> [-Credential <PSCredential>] [-Force] [-NoServiceRestart] [-Confirm][-WhatIf] [<CommonParameters>]
The Enable-SqlAlwaysOn cmdlet enables AlwaysOn on an instance of SQL Server. If AlwaysOn Availability Groups 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 ask whether you wish to restart the service; if cancelled, no operation occurs.
If AlwaysOn Availability Groups is already enabled, this cmdlet does nothing.
This cmdlet can run against a remote service. You must have Administrator permissions to execute this cmdlet.
Parameters |
---|
-Credential <PSCredential>
|
-Force [<SwitchParameter>]
|
-InputObject <Server>
|
-NoServiceRestart [<SwitchParameter>]
|
-Path <string>
|
-ServerInstance <string>
|
-Confirm [<SwitchParameter>]
|
-WhatIf [<SwitchParameter>]
|
<CommonParameters>
|
Inputs
A SMO.Server object referring to the instance of SQL Server on which AlwaysOn should be enabled.
Examples
- This command enables AlwaysOn Availability Groups on the instance of SQL Server located at the specified path:
C:PS> Enable-SqlAlwaysOn -Path SQLSERVER:SqlComputerInstance
This change requires restarting the instance, and you will be prompted to confirm this restart.
- This command enables AlwaysOn Availability Groups on the instance of SQL Server located at the specified path:
C:PS> Enable-SqlAlwaysOn -Path SQLSERVER:SqlComputerInstance -Force
The -Force option causes the server instance to be restarted without prompting you for confirmation.
- This command enables AlwaysOn Availability Groups on the instance of SQL Server named ‘ComputerInstance’:
C:PS> Enable-SqlAlwaysOn -ServerInstance ComputerInstance
This change requires restarting the instance, and you will be prompted to confirm this restart.
- This command enables AlwaysOn Availability Groups on the instance of SQL Server named ‘ComputerInstance’ using Windows authentication:
C:PS> Enable-SqlAlwaysOn -ServerInstance ComputerInstance -Credential (Get-Credential DOMAINUsername)
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.
- This command enables AlwaysOn Availability Groups on the instance of SQL Server located at the specified path, but the command does not restart the instance:
C:PS> Enable-SqlAlwaysOn -Path SQLSERVER:SqlComputerInstance -NoServiceRestart
The change will not take effect until you manually restart this server instance.
Additional Notes
Related Links