运行脚本的推荐方式是
powershell.exe -NonInteractive -Command " & some.ps1 "
但是,例如 TeamCity PowerShell 运行程序使用:
powershell.exe -NonInteractive -Command - < some.ps1
我不知道“- <”是什么意思,也找不到有关该主题的任何信息。有什么帮助吗?
最佳答案
因为 powershell.exe
是通过 Windows shell 调用的,这与您在普通命令提示符 ( cmd.exe
) 上的情况相同。在那种情况下 <
将文件通过管道传输到上一个命令的标准输入 ( stdin
)。 powershell.exe
的帮助表示如果 -Command
的值就是 -
,命令文本是从标准输入中读取的。
这是 <
的更自我记录的演示在 cmd.exe
:
processSomeFile.exe outputFileName.ext < intputFile.ext
关于powershell - 运行powershell时 "- <"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6816923/