BAT回声输出代码PowerShell



我有一个带有此行的蝙蝠脚本:

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中不起作用:(

尝试

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

管道重定向比回声更高,需要逃脱。

最新更新