How to end a multi-line command in PowerShell

Svish picture Svish · Nov 5, 2012 · Viewed 16.3k times · Source

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.

Answer

Svish picture Svish · Nov 5, 2012

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