title: How to pass variable to bcp command within powershell script
body: <p>I am creating a string that I would like to pass to the bcp command from within a PowerShell script. Here is the code that creates the string</p>
  
  <pre><code>$fullFilePath = (pwd).path + "\$db.$table" + ".dat"
  $copyExecString = "bcp $db.$table out $fullFilePath -E -N -Slocalhost"
  </code></pre>
  
  <p>I can paste the Write-host result of this into a command prompt and it runs just fine, but it won't work as follows:</p>
  
  <pre><code>$fullFilePath = (pwd).path + "\$db.$table" + ".dat"
  $copyExecString = "$db.$table out $fullFilePath -E -N -Slocalhost"
  bcp $copyExecString
  </code></pre>
  
  <p>I also tried using the ampersand character before calling the bcp command, but to no avail</p>
  
  <p>Any ideas on how to achieve this functionality would be greatly appreciated</p>