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

家住魔仙堡 提交于 2021-02-09 08:18:06

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/10447609/is-it-possible-to-set-a-users-memberof-property-in-active-directory-using-powers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!