Forum Discussion

Mattw112's avatar
Mattw112
Brass Contributor
Aug 30, 2021

How to create team using custom template

I went into teams admin and created a custom template from an existing team.  All that looks fine.

 

I would like to now automate the creation of teams using that template.

 

I have played with graph and PowerShell but can't figure out how to do this?

 

In PowerShell I'm doing: 

PS C:\WINDOWS\system32> New-Team -DisplayName "TestingTemplates" -Description "Team to test templates" -Visibility Private -Template "MyTemplate"

 

Result is:
New-Team : Cannot validate argument on parameter 'Template'. The argument "MyTemplate" does not belong to the set "EDU_Class,EDU_PLC" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.

 

Preferably I'd like to use Microsoft Power Automate to do this.  So maybe a rest command?  But seems like the template command only works for edu??

 

I have verified my template shows up using:

 

Get-CsTeamTemplateList

 

Thanks,

Terry

 

  • Mattw112 : Hey, I looked into the docs and tried few stuff,.

    Using PowerShell you can only use this two values EDU_Class, EDU_PLC. 

     

    But with Graph you can can create using custom template, it takes few minutes to reflect all changes but it work.

     

    So, when you create template on Teams admin center, you get an Id of that template. (see screenshot) 

     

    Use this Id in request body -> template@odata.bind like this:

     
    {
    "template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('81e86602-a5b9-0000-a6c2-d3f28c576ee3')",
    "displayName": "Beta Team",
    "description": "My Class Description",
    "members": [
    {
    "@odata.type": "#microsoft.graph.aadUserConversationMember",
    "roles": [
    "owner"
    ],
    "user@odata.bind": "https://graph.microsoft.com/beta/users('ef16aa89-0000-0000-aebb-761b551577c0')"
    }
    ]
    }
    

     

    Let us know if you have any query on this.

    Thanks, 

    Hunaid Hanfee 

    -----------------------------------------------------------------------------------------------------------------

    If the response is helpful, please click "Mark as Best Response" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 

Resources