title: Renaming AD user object name in powershell
body: <p>I am trying to get only AD Objects of type user and then iterate over all them and change AD user object name. So I have done below:</p>
  
  <pre><code>$Users = Get-ADObject -Filter {(ObjectClass -eq "user")} # OR Get-ADObject -Filter 'ObjectClass -eq "user"'
  
  $Users | foreach
  {
      # Here code to create name based on conditions ($newUserObjectName)
      Rename-ADObject -Identity $_ -NewName $newUserObjectName
  }
  </code></pre>
  
  <p>The problem is that Get-ADObject is returning not only users but also computer objects.... I only want user object classes. Also I am not sure If below line of code is correct by setting identity to $_ in order to update the current user in the iteration:</p>
  
  <pre><code>Rename-ADObject -Identity $_ -NewName $newUserObjectName
  </code></pre>