为什么是“<"?输入重定向未在 PowerShell 中实现? [英] Why is "<" input redirect not implemented in PowerShell?
问题描述
为什么 输入重定向 未在 PowerShell 中实现?
Why is input redirection not implemented in PowerShell?
做这样的事情:
mysql -u root < create.sql
我不得不切换到cmd.exe".
I had to switch to "cmd.exe".
是否有在 PowerShell 中执行此操作的替代方法?
Is there an alternative way of doing this in PowerShell?
请注意,输出重定向>"是在 PowerShell 中实现的.请在回答之前考虑这一点.
Please note that the output redirection ">" is implemented in PowerShell. Please consider this before giving an answer.
推荐答案
虽然我不完全确定这个问题属于 Stack Overflow,但您是否查看过 PS Cmdlet for Get-Content?在 使用 Get-Content 中查看 TechNet 上的示例中如何使用它Cmdlet.
Although I'm not entirely sure that this question belongs on Stack Overflow, have you looked at the PS Cmdlet for Get-Content? Look how it's used in the examples on TechNet in Using the Get-Content Cmdlet.
示例:
Get-Content c:\scripts\test.txt | Foreach-Object {Get-Wmiobject -computername $_ win32_bios}
更新:以上指向 TechNet 的链接已断开,但 Chad Miller 脚本专家的帖子在评论中提到了 使用 PowerShell 解决遗留重定向问题 提供了三个选项:-use CMD/c
、Echo
和 Get-Content.
Update: Above link to TechNet is broken, but mentioned in comment by Chad Miller Scripting Guy's post Working Around Legacy Redirection Issues with PowerShell gives three options: -use CMD /c
, Echo
, and Get-Content.
这篇关于为什么是“<"?输入重定向未在 PowerShell 中实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!