Adding an ObjectClass to a user

Welcome Forums General PowerShell Q&A Adding an ObjectClass to a user

Viewing 4 reply threads
  • Author
    Posts
    • #234784
      Participant
      Topics: 2
      Replies: 4
      Points: 12
      Rank: Member

      I need to add an objectclass to a user. From researching and google it seems that this should work:

      set-aduser -Identity “nk4978″ -Add @{objectClass=”employeehr”}

      However it yields this error:

      set-aduser : A required attribute is missing
      At line:1 char:1
      + set-aduser -Identity “nk4978″ -Add @{objectClass=”employeehr”}
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : NotSpecified: (nk4978:ADUser) [Set-ADUser], ADException
      + FullyQualifiedErrorId : ActiveDirectoryServer:8316,Microsoft.ActiveDirectory.Management.Commands.SetADUser

       

      So far I am not successful in finding out what these errors mean. From all the examples I’ve found there are no other attributes required. I suspect it has something to do with the objectclass attribute but I am unable to determine what that might be.

      Thanks

       

    • #234787
      Participant
      Topics: 3
      Replies: 417
      Points: 1,462
      Helping Hand
      Rank: Community Hero

      You’ve extended the schema to add that custom attribute?

      https://social.technet.microsoft.com/Forums/office/en-US/d25d6a41-5c02-4924-99e7-6c93265c738a/custom-ad-attributes-using-powershell?forum=winserverDS

      Here is a list of standard attributes.

      http://www.selfadsi.org/user-attributes.htm

      You could also store them in the generic extended attributes.

    • #234952
      Participant
      Topics: 2
      Replies: 4
      Points: 12
      Rank: Member

      The schema has been extended adding the objectclass and it’s accompanying attributes. Modifying attributes is not an issue. Adding an objectclass to a user seems to be a rarely dicussed event.  Google and technet are quite silent about it, at least I have not been able to find references to actually adding an objectclass to an object.

    • #234964
      Participant
      Topics: 2
      Replies: 4
      Points: 12
      Rank: Member

      My error was so obvious I had to slap my forehead! The message:

      set-aduser : A required attribute is missing

      Did not mean something was wrong with my command line, rather that the object I was trying to modify was missing required attributes for the objectclass I wanted to add. DOH! Once I added the two missing “MUST” attributes for the employeehr objectclass the powershell command worked as expected.

       

      Thanks

    • #235135
      Participant
      Topics: 3
      Replies: 417
      Points: 1,462
      Helping Hand
      Rank: Community Hero

      Awesome! Glad you figured it out.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.