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!