Windows Bat回波输出代码PowerShell
我有一个bat脚本,其中有一行:Windows Bat回波输出代码PowerShell,windows,powershell,batch-file,cmd,Windows,Powershell,Batch File,Cmd,我有一个bat脚本,其中有一行: echo ($a = (quser) -replace "\s{2,}" , ";" | Select-String -pattern console -notmatch | Select-string -pattern ID -notmatch)>>ScriptV3.ps1 但当我启动这一行时,我的bat搜索将识别管道|,但在这里,管道是我的PowerShell脚本 如何为批处理脚本隐藏此管道,但我在PowerShell脚本中找到了此管道 谢谢
echo ($a = (quser) -replace "\s{2,}" , ";" | Select-String -pattern console -notmatch | Select-string -pattern ID -notmatch)>>ScriptV3.ps1
但当我启动这一行时,我的bat搜索将识别管道|
,但在这里,管道是我的PowerShell脚本
如何为批处理脚本隐藏此管道,但我在PowerShell脚本中找到了此管道
谢谢大家!
附言:如果我写:
echo "$a = (quser) -replace "\s{2,}" , ";" | Select-String -pattern console -notmatch | Select-string -pattern ID -notmatch">>ScriptV3.ps1
使用quote时,可以批量工作,但不能在PowerShell中工作:(尝试使用
echo ($a = (quser) -replace "\s{2,}" , ";" ^| Select-String -pattern console -notmatch ^| Select-string -pattern ID -notmatch)>>ScriptV3.ps1
管道重定向的优先级高于echo,需要转义。请查看和。如果您显示了生成的ps1文件并解释了您希望它包含的内容,那么对每个人来说都会更容易。