title: Removing A Group Of Controls From a Parent (Winforms Powershell)
body: <p>I have a script I wrote in powershell that creates checkboxes for each user in C:\users</p>
  <p><a href="https://i.stack.imgur.com/9ee61.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ee61.png" alt="Checkboxes" /></a></p>
  <p>I want to remove them from the form as a group but when I use this:</p>
  <pre><code>Foreach ($control in $sourceTab.Controls) {
          if ($control.GetType().ToString() -eq &quot;System.Windows.Forms.CheckBox&quot;){
              $sourceTab.Controls.Remove($control)
          }
      }
  </code></pre>
  <p>It only removes one of the Checkboxes, Not all of them.</p>
  <p><a href="https://i.stack.imgur.com/H0yKc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H0yKc.png" alt="LastCheckBox" /></a></p>
  <p>If I run the code again, it removes the 2nd checkbox as if its only removing them one by one</p>
  <p>I have tried multiple different ways of removing them but for some reason, once it removes one control, it stops the loop. Which I dont understand.</p>