I got two files in C:\temp\SQL\alex.sql and in C:\temp\alex.ps1.
In C:\temp\SQL\alex.sql, that is simply
select count(*) from user_tables;
quit;
In C:\temp\alex.ps1, that is
$cmd = "sqlplus";
$args = "user/password@server/sid @C:\temp\SQL\alex.sql";
&$cmd $args;
I tried the command in Command Prompt
sqlplus user/password@server/sid @C:\temp\SQL\alex.sql which executed perfectly!
The SQL file is not executed at all, but SQL*Plus help is shown.
What did I do wrong? Thanks!
I found the solution myself
I use
cmd.exe /candalex.ps1is nowHope this help.