# encoding: ascii
# api: powershell
# title: Build SQL Server conn st
# description: Build a SQL Server connection string by specifying its parameters.
# version: 0.1
# author: Paulo Morgado
# license: CC0
# x-poshcode-id: 4977
# x-archived: 2014-08-18T21:34:08
# x-published: 2014-03-12T14:07:00
#
#
param (
    [System.Data.SqlClient.ApplicationIntent]$ApplicationIntent,
    [string]$ApplicationName,
    [switch]$AsynchronousProcessing,
    [string]$AttachDBFilename,
    [switch]$ConnectionReset,
    [string]$ConnectionString,
    [int]$ConnectRetryCount,
    [int]$ConnectRetryInterval,
    [int]$ConnectTimeout,
    [switch]$ContextConnection,
    [string]$CurrentLanguage,
    [string]$DataSource,
    [switch]$Encrypt,
    [switch]$Enlist,
    [string]$FailoverPartner,
    [string]$InitialCatalog,
    [switch]$IntegratedSecurity,
    [int]$LoadBalanceTimeout,
    [int]$MaxPoolSize,
    [int]$MinPoolSize,
    [switch]$MultipleActiveResultSets,
    [switch]$MultiSubnetFailover,
    [string]$NetworkLibrary,
    [int]$PacketSize,
    [string]$Password,
    [switch]$PersistSecurityInfo,
    [switch]$Pooling,
    [switch]$Replication,
    [string]$TransactionBinding,
    [switch]$TrustServerCertificate,
    [string]$TypeSystemVersion,
    [string]$UserID,
    [switch]$UserInstance,
    [string]$WorkstationID
)

$builder = New-Object -TypeName System.Data.SqlClient.SqlConnectionStringBuilder

$PSBoundParameters.Keys | % { $key = $_ -creplace '([a-z])([A-Z])', '$1 $2'; $builder[$key] = $PSBoundParameters[$_].ToString() }

$builder.ConnectionString
