Hi,

I’m trying to copy all users in a Microsoft 365 group to a Distribution Group as manual work is taking me ages to complete the job. What i’ve got:

$members = Get-UnifiedGroupLinks -Identity "MICROSOFT365ADDRESS@DOMAIN.COM" -LinkType Members
foreach ($item in $members) {
    Add-DistributionGroupMember -Identity "DISTRIBUTIONLIST@DOMAIN.COM" -member $item
}

Now, it gives me an error back. I’ve tried to select the user alias or primairyemail but thats giving me the exact same error back. Any suggestions?

Error without the ‘| Select’ part:

Cannot process argument transformation on parameter 'Member'. Cannot convert the "**FIRST AND LAST NAME USER**" value of type "Deserialized.Microsoft.E
xchange.Data.Directory.Management.ReducedRecipient" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`1[Microsoft.E
xchange.Configuration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember
    + PSComputerName        : outlook.office365.com

With the ‘| Select’ part:
($members = Get-UnifiedGroupLinks -Identity “MICROSOFT365ADDRESS@DOMAIN.COM” -LinkType Members | Select )

Cannot process argument transformation on parameter 'Member'. Cannot convert the "@{PrimarySmtpAddress=USERACCOUNT@DOMAIN.COM}" value of type "De
serialized.Selected.System.Management.Automation.PSCustomObject" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`
1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember
    + PSComputerName        : outlook.office365.com
2 Spice ups

You are using emailadresses as the Identity, you should try the group name instead.

$members = Get-UnifiedGroupLinks -Identity "Source Group Name" -LinkType Members
foreach ($item in $members) {
    Add-DistributionGroupMember -Identity "Destination Group Name" -member $item
}

Getting the exact same issue then:

Cannot process argument transformation on parameter 'Member'. Cannot convert the "**FIRST NAME AND LAST NAME**" value of type "Deserialized.Microsoft.Exchange.Data
.Directory.Management.ReducedRecipient" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`1[Microsoft.Exchange.Conf
iguration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember
    + PSComputerName        : outlook.office365.com

Try specifying a property on the objects rather than passing the whole object - the member parameter on Add-DistributionGroupMember accepts several different things e.g. alias, email address, guid etc:

$Members = Get-UnifiedGroupLinks -Identity "MICROSOFT365ADDRESS@DOMAIN.COM" -LinkType Members
ForEach ($Item in $Members) {
    Add-DistributionGroupMember -Identity "DISTRIBUTIONLIST@DOMAIN.COM" -Member $Item.Alias
}
1 Spice up

This did the trick! Thanks! :slight_smile: Havent thought of this. I’ve tried piping it through but didnt knew this worked out too haha.

Cheers!

1 Spice up