title: Error on SQL Connection String in Powershell
body: <p>I'm trying to run a sql query from powershell as a scheduled job in SQL server (it's then getting emailed out by the same powershell script) and getting an error I can't sort out.</p>
  
  <pre><code>###
  
  $SqlServer = “localhost”
  $SqlCatalog = “myDatabase”
  $SqlQuery = “select * from MY_VIEW″
  $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
  $SqlConnection.ConnectionString = “server=$SqlServer;Database=$SqlCatalog; user id = myUserid; password=myPassword”
  $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
  $SqlCmd.CommandText = $SqlQuery
  $SqlCmd.Connection = $SqlConnection
  </code></pre>
  
  <p>This is the error I receive:</p>
  
  <p>A job step received an error at line 7 in a PowerShell script. The corresponding line is '$SqlConnection.ConnectionString = "server=$SqlServer;Database=$SqlCatalog; user id = myUserid; password=myPassword"'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Unexpected token 'server=$SqlServer' in expression or statement.  '.</p>
  
  <p>What's wrong with my script?</p>