title: If statement inside a ForEach using csv
body: <p>We are using powershell to create our student users automatically in our Active Directory.  We have everything working except the enable-mailbox.  We only give email addresses to our secondary students.  So I am trying to have the script read the csv and only enable-mailbox for secondary students.  All our secondary schools have campus numbers less than 100, so I tried to have the script use ForEach and then If $_.extensionAttribute1 (column in the csv with the campus number) is less then 100, then it will mail-enable the account.  The problem I am having is that only processes the first user and ends the script.  I am wanting it to run through each row in the csv.  Here is my script.</p>
  
  <pre><code>add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
  
  Import-CSV C:\scripts\updateuser.csv | ForEach {
      $campus =$_.extensionAttribute1
      If ($campus -lt '100') {
      Enable-Mailbox -Identity $_.sAMAccountName -Database NISDSRV6DB1
      }}
  </code></pre>
  
  <p>Any help you can provide to make this run through the entire csv would be greatly appreciated.
  Thank you in advance for your help.</p>
  
  <p>EDIT...I was messing around with the csv file and I got some interesting results.  The only way this script would display anything was if the extensionAttribute1 field was populated with a 1.  I am trying to get all users that are less than 100.  </p>