Bat echo输出代码PowerShell

问题描述 投票:0回答:1

我有一行蝙蝠脚本:

echo ($a = (quser) -replace "\s{2,}" , ";" | Select-String -pattern console -notmatch | Select-string -pattern ID -notmatch)>>ScriptV3.ps1 

但是当我启动这一行时,我的蝙蝠搜索识别管道|,但在这里,管道是我的PowerShell脚本。

如何为我的批处理脚本隐藏此管道,但我在PowerShell脚本中找到此管道。

谢谢 !

PS:如果我写:

echo "$a = (quser) -replace "\s{2,}" , ";" | Select-String -pattern console -notmatch | Select-string -pattern ID -notmatch">>ScriptV3.ps1 

与报价,批量工作但在PowerShell中不起作用:(

windows powershell batch-file cmd
1个回答
1
投票

尝试

echo ($a = (quser) -replace "\s{2,}" , ";" ^| Select-String -pattern console -notmatch ^| Select-string -pattern ID -notmatch)>>ScriptV3.ps1 

管道重定向的优先级高于echo,需要进行转义。

© www.soinside.com 2019 - 2024. All rights reserved.