Поделиться через


Disable-SqlAlwaysOn

Disables the Always On Availability Groups feature for a server.

Синтаксис

ByPath (по умолчанию)

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

ByObject

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

ByName

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

Описание

The Disable-SqlAlwaysOn cmdlet disables the Always On vailability groups feature on a SQL Server instance.

If the Always On Availability Groups feature 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 restart the service.

If the Always On Availability Groups feature is already disabled, this cmdlet makes no changes.

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: Disable Always On Availability Groups at the specified path

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

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

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

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

This command disables 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: Disable Always On Availability Groups for the specified server instance

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

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

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

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

This command disables 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, 'DOMAIN\Username'. This change requires restarting the instance and you will also be prompted to confirm this restart.

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

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

This command disables Always On Availability Groups on the instance of SQL Server 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
Default value:False
Поддерживаются подстановочные знаки:False
DontShow:False
Aliases:cf

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-Credential

Specifies a windows credential that has permission to alter the Always On setting on the SQL Server instance.

Свойства параметра

Тип:PSCredential
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position: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
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-InputObject

Specifies the server object of the instance of SQL Server where the Always On Availability Groups setting is disabled.

Свойства параметра

Тип:Server
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

ByObject
Position: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
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-Path

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

Свойства параметра

Тип:String
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

ByPath
Position:1
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-ServerInstance

Specifies the name of the instance of the SQL Server where Always On is disabled. The format should be MACHINENAME\INSTANCE. Use the Credential parameter to change the Always On setting on a remote server.

Свойства параметра

Тип:String
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

ByName
Position:Named
Обязательно:True
Значение из конвейера:False
Значение из конвейера по имени свойства:True
Значение из оставшихся аргументов:False

-WhatIf

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

Свойства параметра

Тип:SwitchParameter
Default value:False
Поддерживаются подстановочные знаки:False
DontShow:False
Aliases: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

System.String

Выходные данные

System.Object