SOLVED

Trying to add a single user to multiple 365 groups

Copper Contributor

$groups = get-unifiedgroup -filter {(DisplayName -like '*Similar Groups*') -and (DisplayName -ne 'Specific Group I don't want to add')} | select Name

 

Foreach ($group in $groups) { add-unifiedgrouplinks -identity $group -linktype Members -Links singleuser@email.com -whatif }

 

Getting error Cannot process argument transformation on parameter 'Identity'. Cannot convert the 365 group value of type "Deserialized.Selected.System.Management.Automation.PSCustomObject" to type "Microsoft.Exchange.Configuration.Tasks.UnifiedGroupIDParameter". 

2 Replies
best response confirmed by Graham Young (Copper Contributor)
Solution

That's because you are passing the entire object. Try this:

 

Foreach ($group in $groups) { add-unifiedgrouplinks -identity $group.Name -linktype Members -Links singleuser@email.com -whatif }

That did it, thank you!

1 best response

Accepted Solutions
best response confirmed by Graham Young (Copper Contributor)
Solution

That's because you are passing the entire object. Try this:

 

Foreach ($group in $groups) { add-unifiedgrouplinks -identity $group.Name -linktype Members -Links singleuser@email.com -whatif }

View solution in original post