Disable-SqlAlwaysOn

Disables the AlwaysOn Availability Groups feature on the instance of SQL Server specified by the Path,InputObject, or ServerInstance parameter.
Disable-SqlAlwaysOn [[-Path] <string>] [-Credential <PSCredential>] [-Force] [-NoServiceRestart] [-Confirm][-WhatIf] [<CommonParameters>]
Disable-SqlAlwaysOn -InputObject* <Server> [-Credential <PSCredential>] [-Force] [-NoServiceRestart] [-Confirm][-WhatIf] [<CommonParameters>]
Disable-SqlAlwaysOn -ServerInstance* <string> [-Credential <PSCredential>] [-Force] [-NoServiceRestart] [-Confirm][-WhatIf] [<CommonParameters>]

The Disable-SqlAlwaysOn cmdlet disables the AlwaysOn Availability Groups feature on an instance of SQL Server. If AlwaysOn Availability Groups is disabled 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 disabled, this cmdlet does nothing.

This cmdlet can run against a remote service. You must have Administrator permissions to execute this cmdlet.

Parameters
-Credential <PSCredential>

A windows credential that has permission to alter the AlwaysOn setting on the specified instance of SQL Server.

-Force [<SwitchParameter>]

Specify -Force to compel the cmdlet to continue without any confirmation from to the user. This parameter is provided to permit the construction of scripts.

-InputObject <Server>

  • This value is required
  • Accepts pipeline input ByValue

The Server object of the instance of SQL Server where the AlwaysOn Availability Groups setting should be disabled.

-NoServiceRestart [<SwitchParameter>]

  • Default value is False

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.

-Path <string>

The path to the instance of SQL Server. This is an optional parameter. If not specified, the value of this parameter defaults to the current working location.

-ServerInstance <string>

  • This value is required

The name of the instance of SQL Server where AlwaysOn is to be disabled. The format should be MACHINENAMEINSTANCE. Can be used with the -Credential parameter to change the AlwaysOn setting on a remote server.

-Confirm [<SwitchParameter>]

Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]

Describes what would happen if you executed the command without actually executing the command.

<CommonParameters>

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

Inputs

SMO.Server

A SMO.Server object referring the instance of SQL Server on which AlwaysOn should be disabled.

Outputs

False

Examples
  1. This command disables AlwaysOn Availability Groups on the instance of SQL Server located at the specified path:
    C:PS> Disable-SqlAlwaysOn -Path SQLSERVER:SqlComputerInstance
    

    This command requires restarting the server instance, and you will be prompted to confirm this restart.

  2. This command disables AlwaysOn Availability Groups on the instance of SQL Server located at the specified path:
    C:PS> Disable-SqlAlwaysOn -Path SQLSERVER:SqlComputerInstance -Force
    

    The -Force option causes the server instance to be restarted without prompting you for confirmation.

  3. This command disables AlwaysOn Availability Groups on the instance of SQL Server named ‘ComputerInstance’:
    C:PS> Disable-SqlAlwaysOn -ServerInstance ComputerInstance
    

    This command requires restarting the instance, and you will be prompted to confirm this restart.

  4. This command disables AlwaysOn Availability Groups on the instance of SQL Server named ‘ComputerInstance’ using Windows authentication:
    C:PS> Disable-SqlAlwaysOn -ServerInstance ComputerInstance -Credential (Get-Credential DOMAINUsername)
    

    You will be prompted to enter the password for the specified account, ‘DOMAINUsername’. This change requires restarting the instance, and you will also be prompted to confirm this restart.

  5. This command disables AlwaysOn Availability Groups on the instance of SQL Server located at the specified path, but the command does not restart the instance:
    C:PS> Disable-SqlAlwaysOn -Path SQLSERVER:SqlComputerInstance -NoServiceRestart
    

    The change will not take effect until you manually restart this server instance.

Additional Notes
 
Related Links