SOLVED
Home

Add user to multiple teams

%3CLINGO-SUB%20id%3D%22lingo-sub-331116%22%20slang%3D%22en-US%22%3EAdd%20user%20to%20multiple%20teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-331116%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20do%20I%20get%20this%20to%20work%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24teams%20%3D%20Get-Team%20%7C%20Select-Object%20-Property%20GroupId%20%3CBR%20%2F%3EForEach%20(%24team%20in%20%24teams)%20%7B%3CBR%20%2F%3EAdd-TeamUser%20-GroupId%20%24team%20-User%20Adam%40bookkeepingissaquah.com%3CBR%20%2F%3E%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F71998i3B9E2A35519B7D5E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture.PNG%22%20title%3D%22Capture.PNG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EError%20I%20get%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-331116%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-331196%22%20slang%3D%22en-US%22%3ERe%3A%20Add%20user%20to%20multiple%20teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-331196%22%20slang%3D%22en-US%22%3EYour%20right%2C%20its%20working.%20Thank%20you%20so%20much!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-331194%22%20slang%3D%22en-US%22%3ERe%3A%20Add%20user%20to%20multiple%20teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-331194%22%20slang%3D%22en-US%22%3E%3CP%3ESo%20the%20user%20is%20already%20added%2C%20move%20to%20the%20next%20one.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-331188%22%20slang%3D%22en-US%22%3ERe%3A%20Add%20user%20to%20multiple%20teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-331188%22%20slang%3D%22en-US%22%3E%3CP%3EHere%20is%20the%20error%20I%20got%20when%20I%20tried%20that%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F72012i55C0CB1437AFB987%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture2.PNG%22%20title%3D%22Capture2.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-331171%22%20slang%3D%22en-US%22%3ERe%3A%20Add%20user%20to%20multiple%20teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-331171%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20are%20passing%20an%20incorrect%20value%2C%20GroupId%20needs%20to%20be%20string%2C%20while%20you%20are%20passing%20an%20object.%20Try%20this%20instead%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdd-TeamUser%20-GroupId%20%24team.GroupId%20-User%20Adam%40bookkeepingissaquah.com%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Zach_N
Occasional Contributor

How do I get this to work?

 

$teams = Get-Team | Select-Object -Property GroupId 
ForEach ($team in $teams) {
Add-TeamUser -GroupId $team -User Adam@bookkeepingissaquah.com
}

 

Error I getError I get

4 Replies
Highlighted
Solution

You are passing an incorrect value, GroupId needs to be string, while you are passing an object. Try this instead:

 

Add-TeamUser -GroupId $team.GroupId -User Adam@bookkeepingissaquah.com

Highlighted

Here is the error I got when I tried that:

 

Capture2.PNG

Highlighted

So the user is already added, move to the next one.

Highlighted
Your right, its working. Thank you so much!
Related Conversations
Status Unknown
AlexT88 in Microsoft Teams on
1 Replies
Kaizala Custom Action Photo storage
Lisa_sach in Microsoft Kaizala on
2 Replies
Teams message encryption
Thomas_Steibl in Microsoft Teams on
3 Replies