Skip to content

Connect SqlDscDatabaseEngine

dscbot edited this page Jan 19, 2024 · 3 revisions

Connect-SqlDscDatabaseEngine

SYNOPSIS

Connect to a SQL Server Database Engine and return the server object.

SYNTAX

SqlServer (Default)

Connect-SqlDscDatabaseEngine [-ServerName <String>] [-InstanceName <String>] [-StatementTimeout <Int32>]
 [-Encrypt] [<CommonParameters>]

SqlServerWithCredential

Connect-SqlDscDatabaseEngine [-ServerName <String>] [-InstanceName <String>] -Credential <PSCredential>
 [-LoginType <String>] [-StatementTimeout <Int32>] [-Encrypt] [<CommonParameters>]

DESCRIPTION

This command connects to a SQL Server Database Engine instance and returns the Server object.

EXAMPLES

EXAMPLE 1

Connect-SqlDscDatabaseEngine

Connects to the default instance on the local server.

EXAMPLE 2

Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'

Connects to the instance 'MyInstance' on the local server.

EXAMPLE 3

Connect-SqlDscDatabaseEngine -ServerName 'sql.company.local' -InstanceName 'MyInstance'

Connects to the instance 'MyInstance' on the server 'sql.company.local'.

PARAMETERS

-Credential

The credentials to use to impersonate a user when connecting to the SQL Server Database Engine instance. If this parameter is left out, then the current user will be used to connect to the SQL Server Database Engine instance using Windows Integrated authentication.

Type: PSCredential
Parameter Sets: SqlServerWithCredential
Aliases: SetupCredential, DatabaseCredential

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

-Encrypt

Specifies if encryption should be used.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-InstanceName

String containing the SQL Server Database Engine instance to connect to. Default value is 'MSSQLSERVER'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: MSSQLSERVER
Accept pipeline input: False
Accept wildcard characters: False

-LoginType

Specifies which type of logon credential should be used. The valid types are 'WindowsUser' or 'SqlLogin'. Default value is 'WindowsUser' If set to 'WindowsUser' then the it will impersonate using the Windows login specified in the parameter Credential. If set to 'WindowsUser' then the it will impersonate using the native SQL login specified in the parameter Credential.

Type: String
Parameter Sets: SqlServerWithCredential
Aliases:

Required: False
Position: Named
Default value: WindowsUser
Accept pipeline input: False
Accept wildcard characters: False

-ServerName

String containing the host name of the SQL Server to connect to. Default value is the current computer name.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: (Get-ComputerName)
Accept pipeline input: False
Accept wildcard characters: False

-StatementTimeout

Set the query StatementTimeout in seconds. Default 600 seconds (10 minutes).

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 600
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

[Microsoft.SqlServer.Management.Smo.Server]

NOTES

RELATED LINKS

Home

Commands

Resources

Usage

Clone this wiki locally