I\'m trying to write a powershell script which will execute sqlcmd.exe to run a sql script. The script contains a SQLCMD variable which I want to pass in on the command line via
Had the same issue, found the solution accidentally, still don't understand why it works :) (i'm not a powershell pro though):
sqlcmd -d ... -s ... -v Var1Name=("""$PowershellVar1""") Var2Name=("""$PowershellVar2""")
Variables $PowershellVar1
and $PowershellVar2
have string type in my PS script and can contain quotes, spaces etc