Jun 26 2019 09:02 AM
Jun 26 2019 09:12 AM
Jun 26 2019 10:35 AM
Jun 26 2019 11:22 AM
Jun 27 2019 12:13 AM
SolutionThat depends on the specifics I guess. Here's a quick sample of what you can do with PowerShell.
List all groups a given user is a member of:
$dn = (Get-Mailbox user).DistinguishedName Get-Recipient -Filter "Members -eq '$dn'"
Use the above list to add another user as member:
Get-Recipient -Filter "Members -eq '$dn'" | % { Add-DistributionGroupMember $_.Name -Member anotheruser}
That's a really basic code though and it assumes that all the groups are distribution ones. A bit more complex one will check the actual type and use the corresponding cmdlet:
$dn = (Get-Mailbox user).DistinguishedName Get-Recipient -Filter "Members -eq '$dn'" -RecipientTypeDetails GroupMailbox | % { Add-UnifiedGroupLinks $_.Name -LinkType Member -Links anotheruser } Get-Recipient -Filter "Members -eq '$dn'" -RecipientTypeDetails MailUniversalDistributionGroup | % { Add-DistributionGroupMember $_.Name -Member anotheruser }
Jun 27 2019 04:38 PM
Thanks very much indeed, @VasilMichev! This code worked perfectly. Appreciate the help!
All the best!
Feb 12 2021 01:10 PM
@VasilMichev those scripts you provided, after the first one is used, you say
"Use the above list to add another user as member:"
does that second one mean that if the first user has, say, 20 groups, will the second user get added to those 20 groups.
I am just very worried about typing in a command that will alter the system in a way that i did not intend. Thank you.
May 25 2022 03:55 PM
Jun 27 2019 12:13 AM
SolutionThat depends on the specifics I guess. Here's a quick sample of what you can do with PowerShell.
List all groups a given user is a member of:
$dn = (Get-Mailbox user).DistinguishedName Get-Recipient -Filter "Members -eq '$dn'"
Use the above list to add another user as member:
Get-Recipient -Filter "Members -eq '$dn'" | % { Add-DistributionGroupMember $_.Name -Member anotheruser}
That's a really basic code though and it assumes that all the groups are distribution ones. A bit more complex one will check the actual type and use the corresponding cmdlet:
$dn = (Get-Mailbox user).DistinguishedName Get-Recipient -Filter "Members -eq '$dn'" -RecipientTypeDetails GroupMailbox | % { Add-UnifiedGroupLinks $_.Name -LinkType Member -Links anotheruser } Get-Recipient -Filter "Members -eq '$dn'" -RecipientTypeDetails MailUniversalDistributionGroup | % { Add-DistributionGroupMember $_.Name -Member anotheruser }