Is it possible to set a users memberOf property in Active Directory using Powershell

10,055

You cannot modify the MemberOf property - you need to add the user to the group using the Add-ADGroupMember Cmdlet:

Add-ADGroupMember $dn_of_group $user
Share:
10,055
tophatsteve
Author by

tophatsteve

Updated on June 25, 2022

Comments

  • tophatsteve
    tophatsteve almost 2 years

    I need to create a Powershell script that sets some user attributes in Active Directory.

    I'm using the Set-AdUser command and passing in a user object as follows:

    $user = Get-AdUser -Identity $userIdentity
    $user.MemberOf = $dn_of_group
    Set-ADUser -Instance $user
    

    this returns an error of 'The adapter cannot set the value of property "MemberOf"'.

    Is it possible to set the MemberOf property from powershell?

    If so, what am I doing wrong?