如何包含一个“:"作为powershell中的参数? [英] how to include a ":" as a parameter in powershell?

查看:53
本文介绍了如何包含一个“:"作为powershell中的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 powershell 脚本,就像这样

i have a simple powershell script, like this

sqlcmd -S. -E -Q 'select ''$(x)''' -v x="c:a"

但我总是收到错误信息

Sqlcmd: ':a': Invalid argument. Enter '-?' for help.

我发现是参数中的 ":" 导致了问题,但我不知道如何转义它.

i figured out that it is the ":" in the argument caused the problem, but i do not know how to escape it.

谢谢,大卫

推荐答案

抱歉,我不得不再次回答我自己的问题.

sorry that i have to answer to my own question again.

解决这个问题的唯一方法是使用'+'将两个字符串连接起来,':'将被保留.

the only way to solve this problem is to use '+' to concatenate the two string, and the ':' will be reserved.

例如$a="abc"+":123"

e.g. $a="abc"+":123"

这篇关于如何包含一个“:"作为powershell中的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆