title: How to get datasource from Connectionstring using PowerShell?
body: <p>In .Net we can get the datasource from a connectionstring using below mechanism:</p>
  
  <pre><code>System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder(connectionString);
  
  string server = builder.DataSource;
  </code></pre>
  
  <p>I was trying to do that in PowerShell but getting the following exception:</p>
  
  <pre><code>$ConstringObj = New-Object System.Data.SqlClient.SqlConnectionStringBuilder($conString)
  </code></pre>
  
  <blockquote>
    <p>New-Object : Exception calling ".ctor" with "1" argument(s): "Keyword
    not supported: 'metadata'." At line:1 char:17
    + $ConstringObj = New-Object System.Data.SqlClient.SqlConnectionStringBuilder($con ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
        + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand</p>
  </blockquote>
  
  <p>How to do that in PowerShell?</p>