Copy membership from contacts to a user in Powershell

Asked By 50 points N/A Posted on -
qa-featured

In my domain, I have contacts and user accounts with same display names. I want to copy the group membership from contacts and copy to the user accounts then remove the contacts. Is there any script for that? Can I break it down into phases? 

SHARE
Answered By 0 points N/A #148893

Copy membership from contacts to a user in Powershell

qa-featured
HELLO

The purpose is that the main/target users have the same group membership as the main user. Ultimately of the solution is that you need to remove the groups from the target if the source member is not in the group member. The perfect solution in power shell, You need to the follow the code

Sign in to vote
If the purpose is to ensure that the target user has the same group memberships as the source user, A complete solution will also remove groups from the target that the source is not a member of. A complete Power Shell V2 solution, From an old thread follows:
Following is the example for Copy AD accounts with Power Shell.

Get-QADUser for the account and for copy into another account we will use New-QADUser. We can understand by following code.

Get-QADUser 'James Johns' -export | New-QADUser -Parent Container mydomain.local/test -Name 'Janny Grant' -SamAccountName grant -Display Name 'Janny Grant' -First Name Jonny -Last Name Grant -User Password '[email protected]' -import
And for copying the group membership this code will be used.

(Get-QADUser 'James Johns').MemberOf | Add-QADGroupMember -Member ps64jgrant

Login/Register to Answer

Related Questions