PowerShell脚本不接受$(美元)符号 [英] PowerShell script not accepting $ (dollar) sign
本文介绍了PowerShell脚本不接受$(美元)符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用PowerShell脚本打开SQL数据连接,并且密码包含 $
符号:
I am trying to open an SQL data connection using a PowerShell script and my password contains a $
sign:
$cn = new-object system.data.SqlClient.SqlConnection("Data Source=DBNAME;Initial Catalog=Catagory;User ID=User;Password=pass$word;")
当我尝试打开连接时,它说:
When I try to open a connection it says:
登录失败
Login failed
推荐答案
使用反引号将其转义(`)作为美元符号($)的转义字符。
Escape it by using backtick (`) as an escape character for the dollar sign ($).
此外,尝试将语句用单引号引起来,而不要使用双引号引起来现在。
Also, try to enclose the statement in single-quotes instead of the double-quotes you are using now.
这篇关于PowerShell脚本不接受$(美元)符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文