commands

^

New-DbaConnectionStringBuilder

Author zippy1981 , Chrissy LeMaire (@cl)
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out New-DbaConnectionStringBuilder on GitHub.
Want to see the Bill Of Health for this command? Check out New-DbaConnectionStringBuilder.

Synopsis

Returns a Microsoft.Data.SqlClient.SqlConnectionStringBuilder with the string specified

Description

Creates a Microsoft.Data.SqlClient.SqlConnectionStringBuilder from a connection string.

Syntax

New-DbaConnectionStringBuilder
    [[-ConnectionString] <String[]>]
    [[-ApplicationName] <String>]
    [[-DataSource] <String>]
    [[-SqlCredential] <PSCredential>]
    [[-InitialCatalog] <String>]
    [-IntegratedSecurity]
    [[-UserName] <String>]
    [[-Password] <String>]
    [-MultipleActiveResultSets]
    [[-ColumnEncryptionSetting] <String>]
    [-Legacy]
    [-NonPooledConnection]
    [[-WorkstationID] <String>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> New-DbaConnectionStringBuilder

Returns an empty ConnectionStringBuilder

Example: 2
PS C:\> "Data Source=localhost,1433;Initial Catalog=AlwaysEncryptedSample;UID=sa;PWD=alwaysB3Encrypt1ng;Application Name=Always Encrypted Sample MVC App;Column Encryption Setting=enabled" |

New-DbaConnectionStringBuilder
Returns a connection string builder that can be used to connect to the local sql server instance on the default port.

Optional Parameters

-ConnectionString

A Connection String

Alias
Required False
Pipeline true (ByValue)
Default Value
-ApplicationName

The application name to tell SQL Server the connection is associated with.

Alias
Required False
Pipeline false
Default Value dbatools Powershell Module
-DataSource

The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.

Alias SqlInstance
Required False
Pipeline false
Default Value
-SqlCredential

Credential object used to connect to the SQL Server Instance as a different user. This can be a Windows or SQL Server account. Windows users are determined by the existence of a backslash, so if you
are intending to use an alternative Windows connection instead of a SQL login, ensure it contains a backslash.

Alias
Required False
Pipeline false
Default Value
-InitialCatalog

The initial database on the server to connect to.

Alias Database
Required False
Pipeline false
Default Value
-IntegratedSecurity

Sets to use windows authentication.

Alias
Required False
Pipeline false
Default Value False
-UserName

Sql User Name to connect with. Consider using SqlCredential instead.

Alias
Required False
Pipeline false
Default Value
-Password

Password to use to connect with. Consider using SqlCredential instead.

Alias
Required False
Pipeline false
Default Value
-MultipleActiveResultSets

Enable Multiple Active Result Sets.

Alias MARS
Required False
Pipeline false
Default Value False
-ColumnEncryptionSetting

Enable Always Encrypted.

Alias AlwaysEncrypted
Required False
Pipeline false
Default Value
Accepted Values Enabled
-Legacy

Use this switch to create a connection string using System.Data.SqlClient instead of Microsoft.Data.SqlClient.

Alias
Required False
Pipeline false
Default Value False
-NonPooledConnection

If this switch is enabled, a non-pooled connection will be requested.

Alias
Required False
Pipeline false
Default Value False
-WorkstationID

Set the Workstation Id that is associated with the connection.

Alias
Required False
Pipeline false
Default Value $env:COMPUTERNAME
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False