title: How to break Foreach loop in Powershell?
body: <p>I'm looking for a way to break my Foreach loop.</p>
  
  <p>This is my code </p>
  
  <pre><code>$MyArray = @("desktopstudio","controller","storefront","desktopdirector","licenseserver")
  
  $component = "toto,blabla"
  
  $component = $component.Split(",")
  
  foreach ($value in $component)
  {
  
      if ($MyArray -notcontains $value)
      {
          Write-host "Your parameter doesn't match"
          Write-host "Please use one of this parameter $MyArray"
          Break
      }
  
  }
  
  write-host "I'm here"
  </code></pre>
  
  <p>I don't understand why it's not breaking my code, because this is the result when I execute it : </p>
  
  <pre><code>Your parameter doesn't match
  Please use one of this parameter desktopstudio controller storefront desktopdirector licenseserver
  I'm here
  </code></pre>
  
  <p>You can see that my <code>Write-Host "I'm here"</code> is executed while it should not.</p>