Powershell regex for connectionStrings? Powershell regex for connectionStrings? powershell powershell

Powershell regex for connectionStrings?


Use System.Data.Common.DbConnectionStringBuilder

$sb = New-Object System.Data.Common.DbConnectionStringBuilder# Attempting to set the ConnectionString property directly won't work, see below$sb.set_ConnectionString('Data Source=db.sample.com;user id=sample-user;password=sample-password;Initial Catalog=sample-catalog;')$sb

Output:

Key             Value          ---             -----          data source     db.sample.com  user id         sample-user    password        sample-passwordinitial catalog sample-catalog 

See also for more details: DbConnectionStringBuilder does not parse when used in PowerShell

(That is why this funny syntax $sb.set_ConnectionString(...) is used instead of $sb.ConnectionString = ...).