title: How to fix cannot convert system.object[] error
body: <p>I am receiving the following error when running this script: </p>
  
  <blockquote>
    <p>Get-ADGroupMember : Cannot convert 'System.Object[]' to the type 
    'Microsoft.ActiveDirectory.Management.ADGroup' required by parameter 
    'Identity'. Specified method is not supported.</p>
  </blockquote>
  
  <p>Also, the users move from the Win7 group to the Win10 group, but depending on if they are members of the other groups in the if statements, none of the groups in the if statements are moving for any of the users. Please help.</p>
  
  <p>Just for reference the userlist file contains Active Directory usernames in a text file like this:</p>
  
  <pre><code>jsmith
  ksmith
  etc.
  </code></pre>
  
  <p>The grouplist text file contains Active Directory groups like this:</p>
  
  <pre><code>Nitro7
  Project7
  Visio7
  Zoom7
  SnagIt7
  OneNote7
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>Import-Module ActiveDirectory
  
  $users = Get-Content -Path .\userlist.txt
  $group = Get-Content -Path .\grouplist.txt
  $members = Get-ADGroupMember -Identity $group -Recursive
  
  
  foreach ($user in $users){
  Remove-ADGroupMember -Identity "Win7" -Members $user -Confirm:$false -Verbose
  Add-ADGroupMember -Identity "Win10" -Members $user -Confirm:$false -Verbose
  
  If ($members.SamAccountName -contains $user) {
  Remove-ADGroupMember -Identity "Nitro7" -Members $user -Confirm:$false -Verbose
  Add-ADGroupMember -Identity "Nitro10" -Members $user -Confirm:$false -Verbose
  }
  
  If ($members.SamAccountName -contains $user) {
  Remove-ADGroupMember -Identity "Project7" -Members $user -Confirm:$false -Verbose
  Add-ADGroupMember -Identity "Project10" -Members $user -Confirm:$false -Verbose
  }
  
  If ($members.SamAccountName -contains $user) {
  Remove-ADGroupMember -Identity "OneNote7" -Members $user -Confirm:$false -Verbose
  Add-ADGroupMember -Identity "OneNote10" -Members $user -Confirm:$false -Verbose
  }
  
  If ($members.SamAccountName -contains $user) {
  Remove-ADGroupMember -Identity "Zoom7" -Members $user -Confirm:$false -Verbose
  Add-ADGroupMember -Identity "Zoom10" -Members $user -Confirm:$false -Verbose
  }
  
  If ($members.SamAccountName -contains $user) {
  Remove-ADGroupMember -Identity "SnagIt7" -Members $user -Confirm:$false -Verbose
  Add-ADGroupMember -Identity "SnagIt10" -Members $user -Confirm:$false -Verbose
  }
  
  If ($members.SamAccountName -contains $user) {
  Remove-ADGroupMember -Identity "Visio7" -Members $user -Confirm:$false -Verbose
  Add-ADGroupMember -Identity "Visio10" -Members $user -Confirm:$false -Verbose
  }
  }
  </code></pre>