Microsoft Teams is a chat-based workspace for Office 365 – Microsoft
It is one of the emerging applications in Office 365, which helps to bring people to a single place for collaborating on content, conversations, connecting with people, and more…
We can handle Microsoft Teams through the web browser and client-based Microsoft Teams application. We also have Microsoft Graph API to manage Microsoft Teams by managing teams, channels, members, and more.
Microsoft Graph API makes the lives of developers easier, but for IT professionals, it is difficult to control the Teams application. To help them, Microsoft has come up with a PowerShell Module to control the Microsoft Teams.
To get the PowerShell Module to our local environment, we have to get the MicrosoftTeams module from PowerShell Gallery.
Find the MicrosoftTeams PowerShell module from the PowerShell Gallery
- Open Windows PowerShell.
- Run the “Find-Module MicrosoftTeams” command.
Install Microsoft Teams PowerShell module as an Administrator
- Open Windows PowerShell as an Administrator
- Then, run the below command
PS:> Install-Module MicrosoftTeams
- Upon prompt; to trust the untrusted source from PowerShell Gallery, press ‘Y’ and then press ‘Enter’.
Install Microsoft Teams PowerShell module as a normal user
- Open Windows PowerShell as an Administrator
- Then Run the below command
PS:> Install-Module MicrosoftTeams –Scope CurrentUser
- Upon prompt; to trust the untrusted source from PowerShell Gallery, press ‘Y’ and then press ‘Enter’.
Verify the PowerShell module is installed
- Open Windows PowerShell.
- Run the below command
PS:> Get-Module MicrosoftTeams -ListAvailable
- If the command returns the value, then the module is installed. Otherwise, we have to install the module.
Get the list of available cmdlets from Microsoft Teams
After the installation of Microsoft Teams PowerShell module, we can get the list of available commands available in the module to manage and control the Microsoft Teams
- Open Windows PowerShell
- Run the below command to get the list of commands
PS:> Get-Command –Module MicrosoftTeams
- Also, we can run the below command to get the list of commands
PS:> Get-TeamHelp
Based on the screenshot above, below is the list of command and I have linked them to the documentation for each command
Command | Description |
Add-TeamUser | Adds an owner or member to the Team |
Connect-MicrosoftTeams | Connect to the Microsoft Team based on the provided credentials |
Disconnect-MicrosoftTeams | Disconnect from the Microsoft Team |
Get-Team | Returns all the teams that the user belongs to |
Get-TeamChannel | Returns all the channels for a Team |
Get-TeamFunSettings | Returns a team's fun settings |
Get-TeamGuestSettings | Returns Team guest settings |
Get-TeamHelp | Returns a list of commands for Microsoft Teams |
Get-TeamMemberSettings | Returns team member settings |
Get-TeamMessagingSettings | Returns team messaging settings |
Get-TeamUser | Returns all users from the team |
New-Team | Creates a new team |
New-TeamChannel | Add a new channel to the team |
Remove-Team | Deletes a Team |
Remove-TeamChannel | Deletes a channel and this will not delete the content from associated tabs |
Remove-TeamUser | Remove an owner or member from the team. The last owner cannot be removed from the team |
Set-Team | Updates a team properties |
Set-TeamChannel | Updates a team channel settings |
Set-TeamFunSettings | Update Giphy, Stickers and Memes settings |
Set-TeamGuestSettings | Updates team guest settings |
Set-TeamMemberSettings | Updates team member settings |
Set-TeamMessagingSettings | Updates team messaging settings |
Set-TeamPicture | Updates the team picture |
Connect Microsoft Team
- Open Windows PowerShell
- Enter the below command to connect with Microsoft Teams
PS:> Connect-MicrosoftTeams
To get the Teams available for the current user
- Open Windows PowerShell and ensure that the MicrosoftTeams module is installed.
- Run the below command to get the Teams associated to the current user
PS:> $cred = Get-Credential
PS:> Connect-MicrosoftTeams –Credential $cred
PS:> Get-Team
To create a new Team
Below is the syntax used for creating a new team,
New-Team -DisplayName <String> [-Description <String>] [-Alias <String>] [-Classification <String>] [-Visibility <String>] [-DontAddMeAsMember <Boolean>]
Property | Mandatory |
DisplayName | Yes |
Description | No |
Alias | No |
Classification | No |
Visibility | No |
DontAddMeAsMember | No |
Use the below steps to create a new Team,
- Open Windows PowerShell and ensure MicrosoftTeams module is installed
- Run the below command to create a new Team
PS:> $cred = Get-Credential
PS:> Connect-MicrosoftTeams –Credential $cred
PS:> New-Team –DisplayName <NewTeamName>
- It creates a new Team with default owner as a created User. And it also creates the Office 365 group, SharePoint Online Site Collection, Planner.
Update settings to the Team
Below is the syntax for updating the property to the Microsoft Team,
Set-Team -GroupId <String> [-DisplayName <String>] [-Description <String>] [-Alias <String>] [-Classification <String>] [-AccessType <String>]
Property | Mandatory |
GroupId | Yes |
DisplayName | No |
Description | No |
Alias | No |
Classification | No |
AccessType [Public | Private] | No |
The following step used to change the display name for the Team,
- Open Windows PowerShell and ensure MicrosoftTeams module is installed
- Run the below command to change the display name for the TestPowerShell Team
PS:> $cred = Get-Credential
PS:> Connect-MicrosoftTeams –Credential $cred
PS:> Set-Team –GroupId <Team’s Group Id> –DisplayName <NewTeamName>
- It changes the TestPowerShell Team name to PowerShellTeam and you can find the update below.
Delete a Team
Now, we are going to delete the team “PowerShellTeam” from the Microsoft Teams & Office 365.
Below is the syntax to remove the team from the Microsoft teams
Remove-Team -GroupId <String>
- Open Windows PowerShell
- Run the below command to delete the Team from the Microsoft team
PS:> $cred = Get-Credential
PS:> Connect-MicrosoftTeams –Credential $cred
PS:> Remove-Team -GroupId <Team’s Group Id>
- The code removes the Team from the Microsoft team and also removes the associated Office 365 Group, SharePoint Online Team Site Collection and Plan from Microsoft Planner.
Summary
The PowerShell module for Microsoft Teams is in the initial stage and currently, it contains the basic commands to do basic options. Lot more commands are yet to come, so keep your eye on the documentation for each command which are available on GitHub. I’ll bring out the details of other commands in my next article. So stay tuned…