Categories ArticlesOffice 365

Too much fun and games? Control Microsoft Teams with PowerShell

PowerShell has not only made significant inroads into the entire portfolio of products and services offered by Microsoft. It’s also become the foundation Microsoft now uses for building many of these same products and services. That’s why it shouldn’t come as a surprise to anyone that Microsoft Teams, one of the newest editions to Redmond’s stable of products, now includes PowerShell support that allows you to automate and customize the Teams experience in various ways. For those of you who haven’t yet taken the plunge and looked into what Teams is all about, Microsoft describes it as the hub for team collaboration in Office 365 that integrates the people, content, and tools your team needs to be more engaged and effective. In a nutshell, Teams is basically group chat software, but it’s really a lot more than that — especially because of PowerShell support.

Microsoft began providing PowerShell support for Teams back in November 2017 in the form of a PowerShell module you can download from GitHub. Since that time Microsoft has continued adding more cmdlets to this module to the point that you can now do a lot of cool things in Teams with PowerShell. For example, you can use PowerShell to create new teams, add members in bulk, set permissions for members, configure options like assigning pictures to members, create new channels for members to collaborate, or even build a web form users can use to create a new team in self-service fashion without the need of intervention by an administrator.

To get a glimpse of some of the fun and useful things you can do with PowerShell support for Teams, I asked my colleague Vlad Catrinescu to provide us with a brief demo of its capabilities. Vlad is a SharePoint and Office 365 consultant specializing in SharePoint and SharePoint Online deployments as well as hybrid scenarios. As a Pluralsight author, Microsoft Certified Trainer, and recognized international speaker, Vlad has helped hundreds of thousands of users and IT pros across the globe better understand and to get the most out of SharePoint. Vlad is also a Microsoft Most Valuable Professional (MVP) in SharePoint since 2013 and maintains a personal blog called Absolute SharePoint Blog, and he often shares his knowledge by speaking at local conferences and community events. Vlad also blogs at CMSWire as well as Computerworld and is often featured on other Microsoft sites such as Redmond Channel Partner. You can also connect with Vlad on LinkedIn and follow him on Twitter. Let’s now see what Vlad has to show us on leveraging PowerShell in Microsoft Teams.

Controlling Microsoft Teams fun settings (and others) with PowerShell

The way we communicate has changed, and we use emojis, memes, and gifs to communicate with our friends and family in our personal life on Facebook Messenger, WhatsApp, or other platforms that you might be using. Microsoft Teams, which is one of the products taking Office 365 adoption to new levels, brings instant messaging to the enterprise. Microsoft Teams, by default, allows users to use gifs and emojis to express themselves, which can be great, but do you always want this enabled? Some reasons for disabling it can be that you want to make sure that everyone stays serious in a very delicate project, or simply you might want to avoid interpretation problems with teams now split across the globe. You can view multiple examples of those cases in courts nowadays, with three examples here, here, and here!

In order to automate your governance of different teams policies, you first need to get the Microsoft Teams module from the PowerShell Gallery and connect to Microsoft Teams. If you want to do this quickly without multifactor authentication, you can simply copy and paste the next three cmdlets in a PowerShell Window.

Install-Module -Name MicrosoftTeams
$cred = Get-Credential
Connect-MicrosoftTeams -Credential $cred

With multifactor authentication, you can’t pre-create your PS Credential object, so it would look something like this:

Install-Module -Name MicrosoftTeams
Connect-MicrosoftTeams -AccountId

Now, in order to configure settings around memes and gifs, we would use the Set-TeamFunSettings PowerShell cmdlet. (This is also where the blog title comes from.) If I wanted to disable gifs and memes in all the Teams, I could run something similar to the following script:

$Teams = Get-Team
foreach ($team in $Teams){
-GroupId $team.GroupId
-AllowGiphy $false
-AllowStickersAndMemes $false
$ErrorMessage = $_.Exception.Message
Write-Host "$($Team.DisplayName)Failed with error:"
Write-Host $ErrorMessage -ForeGroundcolor Yellow

Another very interesting parameter you have is -GiphyContentRating, which allows you to switch it between “Strict” and “Moderate” if you want to allow gifs, but make sure they are super-safe for work.

This is it for the fun settings, but can we take the same logic and push it to the next level and make it part of a more evolved automated system? Absolutely! Let’s say that I work in an organization that uses Office 365 Groups Classifications of “Open,” “Confidential,” “Secret,” and “Top Secret.” While the Open and Confidential are not as well-regulated, business requires that all groups classified as Secret and Top Secret have the following characteristics:

  • Stickers, memes, and gifs are disabled
  • Users cannot edit messages
  • Users cannot delete messages

I would have to connect to Exchange Online as well in order to get the classification, and I could simply run the following script:

$Teams = Get-Team
Foreach ($team in $Teams)
$OfficeGroupClassification = Get-UnifiedGroup -Identity $team.GroupId | Select Classification
if ($OfficeGroupClassification.Classification -eq "Secret" or $OfficeGroupClassification.Classification -eq "Top Secret")
-GroupId $team.GroupId
-AllowStickersAndMemes $false
-GroupId $team.GroupId
-AllowUserEditMessages $false
-AllowUserDeleteMessages $false

To finish off this quick demo, Microsoft Teams is one of those services that users seem to be adopting at a crazy speed, and it’s our job as IT professionals to make sure that users can be productive while they respect the company security, compliance, and ethics rules. The Teams module for PowerShell allows you to automate certain governance tasks so you can make sure the right settings are always applied to your Microsoft Teams.

Where to learn more

Some resources to learn more about PowerShell for Office 365:

Featured image: Shutterstock

Mitch Tulloch

Mitch Tulloch is Senior Editor of both WServerNews and FitITproNews and is a widely recognized expert on Windows Server and cloud technologies. He has written more than a thousand articles and has authored or been series editor for over 50 books for Microsoft Press and other publishers. Mitch has also been a twelve-time recipient of the Microsoft Most Valuable Professional (MVP) award in the technical category of Cloud and Datacenter Management. He currently runs an IT content development business in Winnipeg, Canada.

Published by
Mitch Tulloch

Recent Posts

New kids vs. old reliable: Can chat apps replace email?

Do businesses rely too heavily on email for communication? Yes! Is the answer to replace email with chat apps? No!…

36 mins ago

PowerShell function to standardize message box script outputs

If you got your start with Visual Basic, you remember msgbox. This PowerShell function will bring back memories and help…

4 hours ago

Microsoft Ignite 2019: Top announcements and product unveilings

Microsoft Ignite 2019 included a slew of updates on products and services. Among the announcements was Azure Arc, which may…

20 hours ago

Who says configuration management can’t be fun?

Managing change in an enterprise isn’t easy and it’s usually no fun. Here’s a book on configuration management that will…

1 day ago

Choosing the right communication tools for your business

Choosing communication tools is like choosing a first progamming language. While you want easy, you also want cross-platform, security, and…

1 day ago

Ignite 2019: Azure Arc extends Azure management across infrastructures

In one of the biggest announcements at this month's Ignite 2019, Microsoft gave us details Azure Arc, a new set…

2 days ago