Get-​Sql​Instance

Gets a SQL Instance object for each instance of SQL Server that is present on the target computer.

Syntax

Get-SqlInstance
   [-Credential] <PSCredential>
   [-MachineName] <String[]>
   [[-Name] <String>]
   [-AutomaticallyAcceptUntrustedCertificates]
   [-ManagementPublicPort <Int32>]
   [-RetryTimeout <Int32>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Get-SqlInstance cmdlet gets a SQL Instance object for each instance of SQL Server that is present on the target computer. If the name of the instance of SQL Server is provided, the cmdlet will only get this specific instance of SQL Server.

You must ensure that you run SQL Server Cloud Adapter on the computer that hosts the instance of SQL Server.

Examples

Example 1: Get an SQL Server instance on a computer

PS C:\> Get-SqlInstance -Credential $Credential -MachineName "Computer002" -Name "InstanceName" -AcceptSelfSignedCertificate;

This command gets the SQL Server instance named InstanceName on the computer named Computer002. The self-signed certificate of the target machine will be automatically accepted without prompting the user.

Example 2: Get all instances of SQL Server on a computer

PS C:\> Get-SqlInstance -Credential $Credential -MachineName "Computer005" -AcceptSelfSignedCertificate;

This command gets all instances of SQL Server on the computer named Computer005. The self-signed certificate of the target machine will be automatically accepted without prompting the user.

Required Parameters

-Credential

Specifies a PSCredential object for the connection to the SQL Server. To obtain a credential object, use the Get-Credential cmdlet. For more information, type Get-Help Get-Credential.

Type:PSCredential
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-MachineName

Specifies the name, as a string array, of the target computer.

Type:String[]
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-AutomaticallyAcceptUntrustedCertificates

Indicates that this cmdlet automatically accepts untrusted certificates.

Type:SwitchParameter
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.The acceptable values for this parameter are:- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ManagementPublicPort

Specifies the public management port on the target computer. This parameter should be used when the ports of the target machine are not directly accessible but are exposed through endpoints, which means that we need to connect to a different port.SQL Server Cloud Adapter must be accessible by this port.

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

Specifies the name of the instance of SQL Server, when you want to retrieve a specific instance of SQL Server on the target machine.

Type:String
Position:2
Default value:None
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 is attempted.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
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
Accept pipeline input:False
Accept wildcard characters:False