Reader small image

You're reading from  Hands-On Microsoft Teams. - Second Edition

Product typeBook
Published inDec 2021
PublisherPackt
ISBN-139781801075275
Edition2nd Edition
Right arrow
Author (1)
João Ferreira
João Ferreira
author image
João Ferreira

João Ferreira is an acclaimed Microsoft MVP, MCP, and MCSA. João has been working with SharePoint for the last 9 years and embraced Microsoft Teams right from day one. João is responsible for the development of several products and is also the owner of 4 blogs: HANDS-ON tek, HANDS-ON SharePoint, HANDS-ON Teams, and HANDS-ON Lists.
Read more about João Ferreira

Right arrow

Microsoft Teams PowerShell: A Tool for Automation

In this chapter, we will cover the PowerShell module available to automate processes with Microsoft Teams. This is the most advanced chapter of the book and will teach you how you can optimize administrative tasks associated with managing Teams.

PowerShell can be very handy and save you a lot of time while managing teams, channels, users' apps, or even policies. In this chapter, you will cover the following topics:

  • What PowerShell is and how you can use it
  • Installing Microsoft Teams PowerShell
  • Cmdlets available in the Microsoft Teams module
  • Learning how to use PowerShell from examples

What PowerShell is

PowerShell is a command-line shell that gives you access to a framework to automate and configure processes on computers.

First released in 2006, it is mainly used on Windows due to the technical architecture that was used in the earlier versions of PowerShell. It recently became available for other platforms, such as Linux and macOS, but most of the modules available do not support these operating systems.

The release of cross-platform PowerShell introduced two versions, Windows PowerShell and PowerShell, each built with a different architecture. To learn more about this topic, I recommend you have a look at the official Microsoft documentation: https://docs.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.1.

Instructions on PowerShell are given through the use of cmdlets. Each cmdlet is responsible for the execution of a specific operation. Cmdlets can be combined into PowerShell scripts...

Installing Microsoft Teams PowerShell

The PowerShell module for Microsoft Teams is not installed by default on Windows, so it needs to be added to the operating system.

Most of the official modules available can be found in the PowerShell Gallery, a site where you can find a description for the module, installation instructions, and also the change log of each version. The PowerShell gallery is available at https://www.powershellgallery.com/.

Important

The Microsoft Teams PowerShell module requires PowerShell 5.1. To find out what version is running on your computer, execute the following cmdlet:

Get-Host | Select-Object Version

If the cmdlet returns a lower version than 5.1, execute the following cmdlet to update it:

Install-Module -Name PowerShellGet -Force -AllowClobber

To get the Microsoft Teams module installed on your system, follow these steps:

  1. On your computer, open the PowerShell command line with administrator...

Cmdlets available in the Microsoft Teams module

Cmdlets in PowerShell use a verb-noun nomenclature to define the action they execute. The verb defines the action itself, while the noun identifies the identity where the action is executed.

To learn more about the approved verbs for PowerShell, we recommend you have a look at the official Microsoft documentation: https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands?view=powershell-7.1.

The selection of cmdlets explained in this section are based on Microsoft Teams module 2.5.1 and they are divided into eight different groups:

  • Connection cmdlets: Use these cmdlets to establish a connection to Microsoft Teams and to disconnect from it once the script finishes its execution
  • Get cmdlets: Use these cmdlets to get information from Microsoft Teams
  • Set cmdlets: Use these cmdlets to modify information in Microsoft Teams
  • New cmdlets...

Learning how to use PowerShell from examples

In this section, you will find three examples of how PowerShell can be used to automate tasks within Microsoft Teams and the script used to tackle each of the scenarios.

The code includes comments so that you can follow along with what is happening. Comments are identified by a hashtag (#).

PowerShell scenario 1: Victor, the IT guy

Victor is the IT guy in his company and his colleagues often ask him to create teams according to internal policies and conventions. To avoid doing this task manually over and over again, Victor has created a PowerShell script that does the process for him.

The following script shows how Victor would do this:

# Define the team settings
$teamName = "Project Y"
$teamDescription = "The new generation of electric skateboards"
$teamOwner = "joao@funskating.com"
$teamVisibility = "Private"
$teamEditMessagesPolicy = $false
$teamDeleteMessagesPolicy...

Summary

In this chapter, you've learned what PowerShell is, its basic concepts, and how it can be used on Windows computers along with the Microsoft Teams module to automate processes. After this chapter, you should be able to build PowerShell scripts to automate the administrative tasks you need to perform in your organization.

This book gave you a global overview of what Microsoft Teams is by covering all the basic features and concepts. As you progressed through the book, it became more technical and gave you an overview of how things can be configured as an end user or as an admin. Finally, you learned how to achieve more by extending Teams and automating processes.

Now, you should be the real hero of Microsoft Teams in your organization, and you are ready to empower others to achieve more using this awesome platform.

Thank you,

João Ferreira.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Microsoft Teams. - Second Edition
Published in: Dec 2021Publisher: PacktISBN-13: 9781801075275
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
João Ferreira

João Ferreira is an acclaimed Microsoft MVP, MCP, and MCSA. João has been working with SharePoint for the last 9 years and embraced Microsoft Teams right from day one. João is responsible for the development of several products and is also the owner of 4 blogs: HANDS-ON tek, HANDS-ON SharePoint, HANDS-ON Teams, and HANDS-ON Lists.
Read more about João Ferreira