Hi,
I am working with a SQL script that's being called from PS
$something = "1111"
Invoke-Sqlcmd -ServerInstance $sqlinst -Database $dbname -Username 'dbuseracccoutn' -Password '********' -Variable "tempKEY=$something" -InputFile $inpfile -Verbose 4>&1 | Tee-Object -Variable statistics
When I run the command above, I am able to pick up $something variable in my SQL
If I change $something = "abc" I get Invoke-Sqlcmd : The name "abc" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
If I change $something = "http://www.securesite.com?a=3&b=f" I get Invoke-Sqlcmd : The format used to define the new variable for Invoke-Sqlcmd cmdlet is invalid. Please use the 'var=value' format for defining a new variable.
Could anyone please point one what I am missing with the format or / and syntax ?
Thanks