I am trying to figure out how I can get the ‘Type’ of an AD object with limited input information. This is for a bulk process where some of the items may be contact records or mail-enabled users or regular AD users with exchange email.
The TYPE will determine the correct command to disable the objects (e.g. remove-mailcontact, disable-mailuser)
I have looked up the ObjectCategory attribute and it doesn’t always give me what I need. Notice that both users and contacts are categorized as Person but the ObjectClass is different. The commands to disable these are different based on that very last item in the Objectclass.
Example: AD View
Name Type OjectCategory ObjectClass
Joe Doe User CN=Person,CN-Scheme,etc top;person;organizationalPerson;user
Jane Doe User CN=Person,CN-Scheme,etc top;person;organizationalPerson;user
Jimmy Doe Contact CN=Person,CN-Scheme,etc top;person;organizationalPerson;contact
Jessie Doe Contact CN=Person,CN-Scheme,etc top;person;organizationalPerson;contact
The key is this: The only information I have going in is EmployeeID (this is not an attribute for a contact record), Name (may not be the correct displayName or first and last name due to legal vs. preferred names) and samaccountname which I may not have for every row.