I wanted to use the SqlConnectionStringBuilder object in the SqlClient area but was having issues accessing the properties. The Object itself is just a collection with a key value structure.
To access the keys use the following PowerShell code:
$builder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $builder.Keys
To set a property just use the key as a reference. For example:
$builder["Data Source"] = $server $builder["Initial Catalog"] = $database $builder["Encrypt"] = $true $builder["TrustServerCertificate"] = $false $builder["User ID"] = $login $builder["Password"] = $password
If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you!