title: PowerShell method Contains not working as expected
body: <p>I am very new to PowerShell and I need to prepare some PowerShell commands to a assign users some roles in Exchange Online. I first need to check if the user is assigned the role already and if not, I'll assign the role. But I just can't figure out how to check if one email address is part of list of email addresses.</p>
  
  <p>I found many discussions on <code>-contains</code> or <code>.Contains</code> method not working but their solutions never worked for me. My code is below.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$L1Group = Get-MsolGroup | Where-Object { $_.DisplayName -eq "TEST_GROUP"}
  $L1Members = Get-MsolGroupMember -GroupObjectId $L1Group.ObjectId
  $CurrentMembers = Get-RoleGroupMember "Recipient Management" |
                    Select -Property WindowsLiveID
  foreach ($user in $L1Members) {
      if (!$CurrentMembers.Contains($user.EmailAddress)) {  
          Add-RoleGroupMember "Recipient Management" -Member $user.EmailAddress
      }
  }
  </code></pre>
  
  <p>It works fine without the <code>if</code> statement and it assigns roles as expected, but I need to skip users who are already members of the role group. I just cant figure out how to make the <code>if</code> statement work. If I use <code>echo $CurrentMembers</code> it returns list of 4 email addresses, just as expected and even if I try</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$CurrentMembers -contains 'MyEmail@MyDomain.com'
  </code></pre>
  
  <p>it always returns False but the address is in the list.</p>