How to end a multi-line command in PowerShell

让人想犯罪 __ 提交于 2019-12-08 15:48:57

问题


This should be easy, but can't figure it out. How do I end a multi-line command in PowerShell? For example if I enter Get-ChildItem | and press enter then I get a >> prompt which I assume is to continue the command. But if I then enter foreach{Write-Host $_.name} and press enter I still get the >> prompt.

How do I say, I'm done, run this now? I thought it would happen when I wrote a complete command (not ending with a pipe or an unclosed bracket), but doesn't seem to. Also tried ending with a semi-colon, but that didn't help much.


回答1:


And right after I asked, I figured it out... Hitting Enter twice made it happen :)




回答2:


If you continue to get >> prompts after pressing enter twice, check your script for unterminated strings, i.e., unpaired quotes.



来源:https://stackoverflow.com/questions/13229066/how-to-end-a-multi-line-command-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!