title: Connect to SQL Server Database from PowerShell
body: <p>I have looked around online for a while now and found many similar problems but for some reason I can't seem to get this working.</p>
  <p>I am just trying to connect to a SQL server database and output the query results to a file - See PowerShell script below. What I am uncertain about is how to integrate the User ID and Password into the connection string.</p>
  <pre><code>$SQLServer = &quot;aaaa.database.windows.net&quot;
  $SQLDBName = &quot;Database&quot;
  $uid =&quot;john&quot;
  $pwd = &quot;pwd123&quot;
  $SqlQuery = &quot;SELECT * from table;&quot;
  $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
  $SqlConnection.ConnectionString = &quot;Server = $SQLServer; Database = $SQLDBName; Integrated Security = True; User ID = $uid; Password = $pwd;&quot;
  $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
  $SqlCmd.CommandText = $SqlQuery
  $SqlCmd.Connection = $SqlConnection
  $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
  $SqlAdapter.SelectCommand = $SqlCmd
  $DataSet = New-Object System.Data.DataSet
  $SqlAdapter.Fill($DataSet)
  
  $DataSet.Tables[0] | out-file &quot;C:\Scripts\xxxx.csv&quot;
  </code></pre>
  <p>The following error message is received:</p>
  <blockquote>
  <p>Exception calling &quot;Fill&quot; with &quot;1&quot; argument(s): &quot;Windows logins are not supported in this version of SQL Server.&quot;</p>
  </blockquote>