PowerShell script not accepting $ (dollar) sign

落爺英雄遲暮 提交于 2019-11-30 11:11:05

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/1615117/powershell-script-not-accepting-dollar-sign

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!