为什么我不能将我的 powershell 命令分成多行?

Why can't I break my powershell command into multiple lines?

这行得通(全部在一条线上):

PS C:\> $list.item | % { $t = $_.tags -split ","; if ($t -contains "red") { $_.name } }

然而,这不是:

PS C:\> $list.item | % {
>> $t = $_.tags -split ","
>> if ($t -contains "red") { $_.ne }
>> }
>>

无论我输入什么,我都会不断收到“>>”提示,直到我按下 Ctrl-C。

怎么了?

要让 powershell 执行命令,您实际上需要按两次 enter。