[英]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.