相关疑难解决方法(0)

为什么在Foreach-Object中继续表现得像break?

如果我在powershell脚本中执行以下操作:

$range = 1..100
ForEach ($_ in $range) {
    if ($_ % 7 -ne 0 ) { continue; }
    Write-Host "$($_) is a multiple of 7"
}
Run Code Online (Sandbox Code Playgroud)

我得到了预期的输出:

7 is a multiple of 7
14 is a multiple of 7
21 is a multiple of 7
28 is a multiple of 7
35 is a multiple of 7
42 is a multiple of 7
49 is a multiple of 7
56 is a multiple of 7
63 is a multiple …
Run Code Online (Sandbox Code Playgroud)

powershell foreach

112
推荐指数
2
解决办法
6万
查看次数

标签 统计

foreach ×1

powershell ×1