title: Add a Check if ExternalEmailAddress already exists in the CSV and if it does do nothing
body: <p>How would I do this? Any ideas? I just want to make sure my script does not try to create a new mailContact if the ExternalEmailAddress already exists.</p>
  <pre><code>If (Test-Path $CSVFileName) {
  
      #Import the CSV file
      $csvfile = Import-CSV $CSVFileName
          
      #Loop through CSV file
      foreach ($line in $csvfile) {
  
          try {
              #Create the mail contact    
              New-MailContact -domaincontroller $dc -Name $line.Name -ExternalEmailAddress $line.ExternalEmailAddress  -OrganizationalUnit $OU -ErrorAction STOP
              Set-Contact -domaincontroller $dc -Identity $line.Name -Department $line.Department -Title &quot;Sales Team&quot; -StreetAddress $line.StreetAddress -City $line.City -StateOrProvince $line.StateOrProvince -PostalCode $line.PostalCode -Office $line.Office -CountryOrRegion $line.CountryOrRegion
              &quot;$($line.Name) was created successfully.&quot; | Out-File $logfile -Append
          }
          catch {
              
              $message = &quot;A problem occured trying to create the $($line.Name) contact&quot;
              $message | Out-File $logfile -Append
              Write-Warning $message
              Write-Warning $_.Exception.Message
              $_.Exception.Message | Out-File $logfile -Append
          }
  
      }
  }
  </code></pre>