public/Set-DbConnectionString.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
function Set-DbConnectionString() { <# .SYNOPSIS Sets the default global connection string and optionally the provider used to create the DbProviderFactory. .DESCRIPTION An alternate ConvertTo-Json method that outputs readable json unlike the native version for Powershell 5 and below. .PARAMETER ConnectionString The string of key pair values that is used to construct a connection to a resource such as a database server. .PARAMETER Name (Optional) The of the Database Provider Factory such as "System.Data.SqlClient", "MySql.Data.MySqlClient", "Npgsql2 Data Provider" .EXAMPLE Set-DbConnectionString "Data Source=(LocalDB)\MSSQLLocalDB;Integrated Security=True" #> [CmdletBinding()] Param( [Parameter(Mandatory = $true, Position = 0)] [String] $ConnectionString, [String] $Name = "Default" ) Process { Set-SqlDbOption -Name "ConnectionStrings/$Name" -Value $ConnectionString } } |