{"id":3028,"date":"2020-10-14T15:46:37","date_gmt":"2020-10-14T20:46:37","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=3028"},"modified":"2020-10-14T16:06:38","modified_gmt":"2020-10-14T21:06:38","slug":"how-to-manage-microsoft-teams-using-powershell","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=3028","title":{"rendered":"How to Manage Microsoft Teams using PowerShell"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Install the Teams PowerShell Module<\/h4>\n\n\n\n<p>The first step in managing Teams via PowerShell is to install the Teams Cmdlets module.\u00a0 Running PowerShell as an Administrator, you will need to run the following and allow install from the untrusted repo as well as installing the NuGet package:<\/p>\n\n\n\n<p><br><code><span class=\"has-inline-color has-primary-color\">Install-Module -Name MicrosoftTeams<\/span><\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/1.png\" alt=\"Manage Microsoft Teams PowerShell Code\" width=\"1098\" height=\"343\" srcset=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/1.png 1098w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/1-300x94.png 300w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/1-768x240.png 768w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/1-1024x320.png 1024w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/1-200x62.png 200w\"><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Connect PowerShell to the Tenant<\/h4>\n\n\n\n<p>The next step is to connect to Teams in the tenant.\u00a0 This can be done with the following script.<\/p>\n\n\n\n<p><span class=\"has-inline-color has-primary-color\">$UserCredential = Get-Credential<br>Connect-MicrosoftTeams -Credential $UserCredential<\/span><\/p>\n\n\n\n<p><br>Voila\u2026you are connected to Microsoft Teams as long as you have the appropriate rights.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/2.png\" alt=\"\" class=\"wp-image-9322\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Show Available Cmdlets<\/h4>\n\n\n\n<p>You can now run <span class=\"has-inline-color has-primary-color\">Get-Command -Module MicrosoftTeams<\/span> to list the available cmdlets.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/3.png\" alt=\"Manage Microsoft Teams Admin Windows PowerShell\" class=\"wp-image-9323\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">New Team PowerShell Options<\/h4>\n\n\n\n<p>For this example, we will create a new Team.&nbsp; If we look at the results of a Get-Help New-Team -Full, you can see the syntax of the command as well as the parameters.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/4.png\" alt=\"\" class=\"wp-image-9324\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Create the Team<\/h4>\n\n\n\n<p>We can create a new team.<\/p>\n\n\n\n<p><span class=\"has-inline-color has-primary-color\">New-Team -DisplayName \u201cUK Finance Team\u201d -AccessType Private -Description \u201cThis Team is for UK Finance\u201d<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/5.png\" alt=\"PowerShell Admin Command to Manage Microsoft Teams\" class=\"wp-image-9325\"\/><\/figure>\n\n\n\n<p>This will provide us with the GroupID for the Team so we know the cmdlet was successful.&nbsp; The Team is created, but it does not have membership, channels, or settings.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add Members and Channels<\/h4>\n\n\n\n<p>To do this we can run Add-TeamUser, New-TeamChannel and a host of Set-Team other settings that aren\u2019t covered here, but you can find more details of these in the\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/teams\/set-team?view=teams-ps\">Microsoft documentation<\/a>.<\/p>\n\n\n\n<p><span class=\"has-inline-color has-primary-color\">Add-TeamUser -GroupId 4a07317c-c860-47db-9a85-00113764d528 -User user@domain.onmicrosoft.com<br>New-TeamChannel -GroupId 4a07317c-c860-47db-9a85-00113764d528 -DisplayName &#8220;Regulatory Compliance&#8221;<\/span><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><code><br><span class=\"has-inline-color has-primary-color\">Id DisplayName Description<\/span><\/code><\/p>\n\n\n\n<p><code><br><span class=\"has-inline-color has-primary-color\">-- ----------- -----------<br>19:77e332ebe56c494181372e509b44251c@thread.skype Regulatory Compliance<\/span><br><\/code><br><img loading=\"lazy\" decoding=\"async\" width=\"1077\" height=\"228\" srcset=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/6.png 1077w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/6-300x64.png 300w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/6-768x163.png 768w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/6-1024x217.png 1024w, https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/6-200x42.png 200w\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/6.png\" alt=\"\"><\/p>\n\n\n\n<p>A member has been added to the Team, and a new channel has been created.&nbsp; You will notice that the channel has an ID associated with it that will be needed for the management of that channel.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Modify Settings<\/h4>\n\n\n\n<p>I mentioned I would not cover all the settings cmdlets, but I will briefly cover the TeamMemberSettings as an example because I want my users to create channels but not delete them, and I also do not want them to add\/remove Apps.\u00a0 I can run Set-TeamMemberSettings to do this.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><span class=\"has-inline-color has-primary-color\">Set-TeamMemberSettings -GroupId 4a07317c-c860-47db-9a85-00113764d528 -AllowCreateUpdateChannels true -AllowDeleteChannels false -AllowAddRemoveApps false<\/span><\/p>\n\n\n\n<p><br><img loading=\"lazy\" decoding=\"async\" width=\"1078\" height=\"85\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/7.png\" alt=\"\"><\/p>\n\n\n\n<p>I now have my team created \u201cmostly\u201d as I would like but it has taken me a while and a lot of commands to do this.&nbsp; Let me delete the team.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Remove the Team<\/h4>\n\n\n\n<p><span class=\"has-inline-color has-primary-color\">Remove-Team -GroupId 4a07317c-c860-47db-9a85-00113764d528<\/span><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Scripting the Team Creation<\/h4>\n\n\n\n<p>Now I can script the entire thing like this with the groupid captured from the initial creation.<\/p>\n\n\n\n<p><span class=\"has-inline-color has-primary-color\">$group = New-Team -DisplayName &#8220;UK Finance Team&#8221; -AccessType Private -Description &#8220;This Team is for UK Finance&#8221;<br>Add-TeamUser -GroupId $group.GroupId -User &#8220;user@domain.onmicrosoft.com&#8221;<br>New-TeamChannel -GroupId $group.GroupId -DisplayName &#8220;Regulatory Compliance&#8221;<br>Set-TeamMemberSettings -GroupId $group.GroupId -AllowCreateUpdateChannels true -AllowDeleteChannels false -AllowAddRemoveApps false<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.quadrotech-it.com\/wp-content\/uploads\/2019\/05\/8.png\" alt=\"\" class=\"wp-image-9328\"\/><\/figure>\n\n\n\n<p>That is a bit more straightforward, but it could still be easier.&nbsp; Microsoft has impeded a beta feature, for now, to easily create a team based on a template.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install the Teams PowerShell Module The first step in managing Teams via PowerShell is to install the Teams Cmdlets module.\u00a0 Running PowerShell as an Administrator, you will need to run the following and allow install from the untrusted repo as well as installing the NuGet package: Install-Module -Name MicrosoftTeams Connect PowerShell to the Tenant The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60,59],"tags":[75,76],"class_list":["post-3028","post","type-post","status-publish","format-standard","hentry","category-office-365","category-powershell","tag-microsoft-teams","tag-teams"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3028"}],"version-history":[{"count":25,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3028\/revisions"}],"predecessor-version":[{"id":3053,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3028\/revisions\/3053"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}