title: Execute SQL*Plus from PowerShell
body: <p>I got two files in <code>C:\temp\SQL\alex.sql</code> and in <code>C:\temp\alex.ps1</code>.</p>
  
  <p>In <code>C:\temp\SQL\alex.sql</code>, that is simply</p>
  
  <pre><code>select count(*) from user_tables;
  quit;
  </code></pre>
  
  <p>In <code>C:\temp\alex.ps1</code>, that is</p>
  
  <pre><code>$cmd = "sqlplus";
  $args = "user/password@server/sid @C:\temp\SQL\alex.sql";
  &amp;$cmd $args;
  </code></pre>
  
  <p>I tried the command in Command Prompt</p>
  
  <p><code>sqlplus user/password@server/sid @C:\temp\SQL\alex.sql</code> which executed perfectly!</p>
  
  <p>The SQL file is not executed at all, but <strong>SQL*Plus help</strong> is shown.</p>
  
  <p>What did I do wrong? Thanks!</p>