Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Problem copying group membership

$
0
0

I often have to copy the members of an AD group to another group.  In theory this should be easy:

Get-ADGroupMember -Identity 'Source' | Add-ADPrincipalGroupMembership -MemberOf 'Target'

Unfortunately, if any of the members of the source group are already in the target group, the pipeline stops with the warning message, "The specified account name is already a member of the group" and then refuses to try adding any of the other users.  Being a warning and not an error, -ErrorAction SilentlyContinue does not help either.

I know I could script around this with a foreach loop but surely this should not be necessary?  Thanks for any suggestions!


Viewing all articles
Browse latest Browse all 6937

Trending Articles