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 [email protected]

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){
try{
Set-TeamFunSettings
-GroupId $team.GroupId
-AllowGiphy $false
-AllowStickersAndMemes $false
}
catch{
$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.

Microsoft Teams

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")
{
Set-TeamFunSettings
-GroupId $team.GroupId
-AllowStickersAndMemes $false
Set-TeamMessagingSettings
-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

2 thoughts on “Too much fun and games? Control Microsoft Teams with PowerShell”

  1. hi there, this article is very useful. Thank you.
    Please may i ask what can we do to disable emojis? i work in a school and due to covid19, we are having to deliver lessons online.. as consequence, the kids are using emojis to distract eachother.. they add a ton of blank used up space, which means the teachers having to scroll for a while to find a genunine question posting.. only to then be sent back to the bottom when a new emoji/posting is added.
    Many thanks for any help you can give.. pshell definately seems the solution here.

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top