Stop-SqlInstance

Stops the specified instance of SQL Server.

Syntax

Stop-SqlInstance
    [-Path <String[]>]
    [-Credential] <PSCredential>
    [-AutomaticallyAcceptUntrustedCertificates]
    [-ManagementPublicPort <Int32>]
    [-RetryTimeout <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Stop-SqlInstance
    -InputObject <Server[]>
    [-Credential] <PSCredential>
    [-AutomaticallyAcceptUntrustedCertificates]
    [-ManagementPublicPort <Int32>]
    [-RetryTimeout <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Stop-SqlInstance
    -ServerInstance <String[]>
    [-Credential] <PSCredential>
    [-AutomaticallyAcceptUntrustedCertificates]
    [-ManagementPublicPort <Int32>]
    [-RetryTimeout <Int32>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Stop-SqlInstance cmdlet stops the specified instance of SQL Server.

SQL Server Cloud Adapter must be running and accessible on the computer that hosts the instance of SQL Server.

This cmdlet supports the following modes of operation:

  • Specify the instance Windows PowerShell path.
  • Specify the server object.
  • Specify the ServerInstance object of the target instance of SQL Server.

Note: This cmdlet ceased to work a long time ago. It's been removed in version 22 of the module.

Examples

Example 1: Stop an instance of SQL Server

PS C:\> CD SQLSERVER:\SQL\Computer\Instance
PS SQLSERVER:\SQL\Computer\Instance> Stop-SqlInstance -Credential $Credential -AcceptSelfSignedCertificate

The first command changes the working directory to SQLSERVER:\SQL\Computer\Instance.

Example 2: Stop all instances of SQL Server on the specified computer

PS C:\> Get-SqlInstance -Credential $Credential -MachineName "Computer006" | Stop-SqlInstance -Credential $Credential -AcceptSelfSignedCertificate

This command retrieves all instances of SQL Server on the machine named Computer006 and stops all the instances. The self-signed certificate of the target computer is automatically accepted without prompting the user.

Parameters

-AutomaticallyAcceptUntrustedCertificates

Indicates that this cmdlet automatically accepts untrusted certificates.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Credential

Specifies a user account with Windows Administrator credentials on the target computer.

Type:PSCredential
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Specifies an array of server objects of the target instance.

Type:Server[]
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ManagementPublicPort

Specifies the public management port on the target computer. This parameter is used when the ports of the target computer are not directly accessible but are exposed through endpoints. This means that this cmdlet needs to connect to a different port.

SQL Server Cloud Adapter must be accessible by this port.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Path

Specifies the path to the instance of SQL Server, as a string array, on which this cmdlet runs the operation. If you do not specify a value for this parameter, the cmdlet uses the current working location.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RetryTimeout

Specifies the time period to retry the command on the target server. After the timeout expires, no retry will be attempted.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ServerInstance

Specifies the name of an instance of SQL Server, as a string array, that becomes the target of the operation.

Type:String[]
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.SqlServer.Management.Smo.Server[]

System.String[]