1

Problem

Get-ADObject -Filter {ObjectClass = "User"}

Returns both users and computers. The object classes display correctly as "user" or "computer".

Get-ADobject -Filter {ObjectClass = "Computer"}

Returns only computers.

Other Observations

Get-ADObject "CN=desktop1,CN=Computers,DC=contoso,DC=com" `
| Get-Member -Property ObjectClass

Returns

TypeName: Microsoft.ActiveDirectory.Management.ADObject

Name              MemberType            Definition
----              ----------            ----------
ObjectClass       Property              System.String ObjectClass {get;set;}

Furthermore, this returns False, as expected:

$(Get-ADObject "CN=desktop1,CN=Computers,DC=contoso,DC=com").ObjectClass -eq "User"

1 Answer 1

8

Queries with objectClass=User return user and computer objects, because the computer class is derived from the user class. If you want just user objects, filter for objectClass=User and objectCategory=Person. See here.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah! I had expected them to be exclusive, because I see them both as top schema objects and missed the "subClassof" property of "computer" being equal to "user". I did not realize the association existed. Thank you very much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.