I wrote a powershell script that can be run from powershell like so:
PS C:> S:\MyScript.ps1 -a "select thing from table where name like 'name'"
I've stored it on a shared drive (S:), and I cannot run my powershell script in this form from either powershell or cmd.exe:
PS C:> powershell S:\MyScript.ps1 -a "select thing from table where name like 'name'"
C:\> powershell S:\MyScript.ps1 -a "select thing from table where name like 'name'"
I've also tried to run it bypassing the executionpolicy:
C:\> powershell -executionpolicy bypass -command S:\MyScript.ps1 -a "select thing from table where name like 'name'"
I've also tried to run it with the full UNC path (in all the forms above):
C:\> powershell \\MyServer\path\to\MyScript.ps1 -a "select thing from table where name like 'name'"
The only form that shows output is if I use a parameter that doesn't require a string to be passed:
C:\> powershell S:\MyScript.ps1 -z
thing
-----
thing1
thing2
thing3
Does anyone know why this is? Is there some way I can pass a string to the script from cmd.exe?