当我们在PowerShell中运行以下命令时:
它抱怨道:
get-date | sc C:\temp\date.log
它会创建一个名为date.log的文件,并使用当前日期进行命名。
但是,如果我们通过CMD运行相同的命令:
powershell get-date | sc C:\temp\date.log
它抱怨道:
ERROR: Unrecognized command
DESCRIPTION: SC is a command line program used for communicating with the Service Control Manager and services. USAGE: sc <server> [command] [service name] <option1> <option2>...
显然,CMD混淆了为POSH准备的管道和自己的管道。
有人能指点我如何通过CMD运行它吗?
提前感谢。