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 vlad@contoso.com

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.

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

Mitch Tulloch

Mitch Tulloch is a widely recognized expert on Windows Server and cloud technologies who has written more than a thousand articles and has authored or been series editor for over 50 books for Microsoft Press. He is a twelve-time recipient of the Microsoft Most Valuable Professional (MVP) award in the technical category of Cloud and Datacenter Management.

Share
Published by
Mitch Tulloch

Recent Posts

An overview of PCI DSS and a guide to compliance

PCI DSS is the globally recognized security standard for any business that processes credit card payments. Are you in compliance…

14 hours ago

Quick tip: Runbook script to start and stop your Azure Firewall

In this blog post, we are going over a simple script that can be used as an Azure runbook to…

19 hours ago

Private 5G networks: Everything you need to know

We are on the verge of the rollout of public 5G networks. And following close behind is the reality of…

22 hours ago

On-premises backup for cloud data and cloud infrastructure protection

On-premises backup is a down-to-earth solution for backing up your cloud data – especially for those with a healthy paranoia…

2 days ago

Lenovo adds to lineups of ThinkBook laptops for SMBs

Lenovo’s new ThinkBook lineup brings agile collaboration features and enterprise-grade infrastructure and security to SMBs.

2 days ago

Control your business data: Managing the unmanaged mobile devices

Can we allow companies to control their business data while allowing employees to access that data on their personal mobile…

2 days ago