![](/img/trans.png)
[英]How to use “OR” and pipe in windows powershell command for findstr
[英]How to use Pipe (|) in powershell -Command …?
我想从 Windows 控制台命令行执行 powershell 命令。 我的方法是:
c:\>powershell -Command mypowershellstatment1;mypowershellstatment1;etc
问题:
In case if a complex powershell command contains powershell pipe operator, then it seems that Windows console interprets it, instead of passing it literally as parameter to the powershell executable.
例如:
c:\>powershell -Command mypowershellstatment1 | anything;mypowershellstatment1;etc
给出标准控制台错误消息“'anything' 不被识别为内部或外部命令”可运行程序或批处理文件。
问题
如何克服这个问题?
自从|
cmd中有类似的function,需要转义。
在 cmd 中,适当的转义序列为^|
:
C:\>powershell -Command Get-Something ^| Do-Something
powershell “command1 | command2 | command3 ... | commandN-1 | commandN”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.