title: How can I run sqlcmd.exe using PowerShell?
body: <p>I have something that I can run using cmd.exe but now want to do this in PowerShell. How can I rewrite this to work in PowerShell?</p>
  
  <pre><code>#username of db
  set username=user
  set pwd= password1
  #server IP or server name 
  set server=test/database1
  #database name you are logging into
  set dbname=database1
  #sql file name
  set sqlScript=C:\Scripts\testTables.sql
  
  sqlcmd.exe  -S%server% -U%username% -P%pwd%   -d%dbname% -o"tables.lis"  -i %sqlScript%
  </code></pre>