title: How to exit from ForEach-Object in PowerShell
body: <p>I have the following code:</p>
  <pre><code>$project.PropertyGroup | Foreach-Object {
      if($_.GetAttribute('Condition').Trim() -eq $propertyGroupConditionName.Trim()) {
          $a = $project.RemoveChild($_);
          Write-Host $_.GetAttribute('Condition')&quot;has been removed.&quot;;
      }
  };
  </code></pre>
  <p>Question #1: How do I exit from ForEach-Object? I tried using &quot;break&quot; and &quot;continue&quot;, but it doesn't work.</p>
  <p>Question #2: I found that I can alter the list within a <code>foreach</code> loop... We can't do it like that in C#... Why does PowerShell allow us to do that?</p>