title: Powershell failure to connect to SQL Server
body: <p>I am trying to send some basic data to a SQL Server hosted on our company website. My web dev checked on the Server side and the connection is allowed but I keep getting this response from PowerShell:</p>
  
  <blockquote>
    <p>Exception calling "Open" with "0" argument(s):<br>
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</p>
  </blockquote>
  
  <p>I have verified the credentials are all correct. MySQL Workbench logged into the SQL server without issues.</p>
  
  <p>This is my connection code. The connection values are edited for obvious security reasons.</p>
  
  <pre><code>function upload_SQL () {
      $SQLServer = "server.com"
      $SQLDBName = "DB_Name"
      $uid ="User_Name"
      $pwd = "Pass"
  
      Write-Host "Attempting to connect to $SQLServer"
      $ConnectionString = "Server=$SQLServer; Database=$SQLDBName; Integrated Security=True; User ID=$uid; Password=$pwd;"
      $conn = New-Object System.Data.SqlClient.SqlConnection($ConnectionString)
      $conn.Open()
      $SqlQuery = $conn.CreateCommand()
      $SqlQuery.CommandText = "INSERT INTO total2_gariondata.Test () VALUES ('
              $DTinfo,
              $ClientCode,
              $CompCode,
              $CPUstat, 
              $MEMstat, 
              $DSKstat,
              $TimePeriods,
              $CritErr1,
              $WarnErr1,
              $SpaceUsed
          ');"
      $SqlQuery.ExecuteNonQuery()
      $conn.Close()
  }
  </code></pre>