Copy Users from One SharePoint Group to Another using PowerShell

Recently, I had a requirement to copy users from one SharePoint group to another group. Unfortunately, SharePoint doesn't support nested groups. Simply renaming the group didn't help us! Well, There is no direct way to copy users from one group to another, but without having to retype each user IDs, you can use this trick to save time in copy-move SharePoint users:

Copy users from one SharePoint site collection to another using PowerShell:
The above script copies users between SharePoint groups of the same site. Can we copy users between groups in different site collections? Why not? Lets change the above script slightly to copy users from one SharePoint site group to another.

#Iterate through each users in the source group foreach ($user in $SourceGroup.users) { $TargetGroup.AddUser($user) Write-Host "Copied $user from $SourceGroup to $TargetGroup" #To move users, Just remove them from source group #$SourceGroup.RemoveUser($user) }}

Total Views

Disclaimer

This is my personal blog. Articles written on this blog are from my experience for my own reference and to help others.

Do not reproduce my content anywhere, in any form without my permission. If any article written on this blog violates copyright, please contact me! If you have a more elegant solution on any of the topics discussed- please post a comment, I'll be happy to hear!

This site uses cookies to personalize content, advertisements and to analyze traffic.