是否可以使用 Powershell 从模板创建 Microsoft 团队?
Is it possible to create a Microsoft team from a template with Powershell?
我目前正在编写 Powershell 脚本以在 Microsoft Teams 中创建团队。
在 Powershell 中创建团队时是否可以使用模板?
提前致谢。
是的,这是可能的,但是 不是 MicrosoftTeamsPowerShell
模块的 New-Team
。根据 the docs,-Template
参数适用于教育客户:
If you have an EDU license, you can use this parameter to specify which template you'd like to use for creating your group. Do not use this parameter when converting an existing group.
Valid values are: "EDU_Class" or "EDU_PLC"
相反,您可以使用 Microsoft Graph 执行此操作,尤其是 Create Team
操作。 One of the examples listed in the docs describes how to use the AdditionalProperties to specify a template, and once you know it's possible in Graph in concept, it's simply a case of finding the matching operation in the Microsoft Graph PowerShell module, in this case New-MgTeam
(more info here).
对于一些最终代码,您可以使用以下代码:
Connect-MgGraph -Scopes "Team.Create"
$additionalProperties = @{
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('com.microsoft.teams.template.ManageAProject')"
}
New-MgTeam -DisplayName "SOTest" -AdditionalProperties $additionalProperties
此示例使用 Project Team 模板 - 这里是 out of box templates. For your custom templates, you can create them in the admin centre or via PowerShell, and you can read more about them here 的列表。要实际 使用 自定义模板,您可以使用它的 Guid 形式:
$additionalProperties = @{
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('[your guid here]')"
}
最后一点要注意——PowerShell 命令执行得非常快,它创建初始团队的速度也非常快,但之后应用模板(例如创建频道等)需要几分钟时间- 给它 5 - 10 分钟,应该没问题。
我目前正在编写 Powershell 脚本以在 Microsoft Teams 中创建团队。
在 Powershell 中创建团队时是否可以使用模板?
提前致谢。
是的,这是可能的,但是 不是 MicrosoftTeamsPowerShell
模块的 New-Team
。根据 the docs,-Template
参数适用于教育客户:
If you have an EDU license, you can use this parameter to specify which template you'd like to use for creating your group. Do not use this parameter when converting an existing group. Valid values are: "EDU_Class" or "EDU_PLC"
相反,您可以使用 Microsoft Graph 执行此操作,尤其是 Create Team
操作。 One of the examples listed in the docs describes how to use the AdditionalProperties to specify a template, and once you know it's possible in Graph in concept, it's simply a case of finding the matching operation in the Microsoft Graph PowerShell module, in this case New-MgTeam
(more info here).
对于一些最终代码,您可以使用以下代码:
Connect-MgGraph -Scopes "Team.Create"
$additionalProperties = @{
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('com.microsoft.teams.template.ManageAProject')"
}
New-MgTeam -DisplayName "SOTest" -AdditionalProperties $additionalProperties
此示例使用 Project Team 模板 - 这里是 out of box templates. For your custom templates, you can create them in the admin centre or via PowerShell, and you can read more about them here 的列表。要实际 使用 自定义模板,您可以使用它的 Guid 形式:
$additionalProperties = @{
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('[your guid here]')"
}
最后一点要注意——PowerShell 命令执行得非常快,它创建初始团队的速度也非常快,但之后应用模板(例如创建频道等)需要几分钟时间- 给它 5 - 10 分钟,应该没问题。