title: Run a shell command with arguments from powershell script
body: <p>I need to extract and save a some tables from a remote SQL database using bcp. I would like to write a powershell script to invoke bcp for each table and save the data. So far I have this script that creates the necessary args for bcp. However I can not figure out how to pass the args to bcp. Every time I run the script it just shows the bcp help instead. This must be something really easy that I am not getting.</p>
  
  <pre><code>#commands bcp database.dbo.tablename out c:\temp\users.txt -N -t, -U uname -P pwd -S &lt;servername&gt;
  $bcp_path = "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe"
  $serverinfo =@{}
  $serverinfo.add('table','database.dbo.tablename')
  $serverinfo.add('uid','uname')
  $serverinfo.add('pwd','pwd')
  $serverinfo.add('server','servername')
  $out_path= "c:\Temp\db\"
  $args = "$($serverinfo['table']) out $($out_path)test.dat -N -t, -U $($serverinfo['uid']) -P $($serverinfo['pwd']) -S $($serverinfo['server'])"
  
  #this is the part I can't figure out
  &amp; $bcp_path $args
  </code></pre>