365tips.be

The best Microsoft 365 tips on the web

Here are the 20 most commonly used PowerShell scripts for managing Microsoft Teams

These 20 PowerShellscripts help manage Microsoft Teams and provide control over key aspects of Teams, such as creating and managing Teams and channels, adding and deleting members, and archiving and de-archiving Teams. Remember to connect to Microsoft Teams via PowerShell before running these scripts, as described in script 1.

1. Connect with Microsoft Teams

This script helps you connect to Microsoft Teams via PowerShell, which is necessary to run Teams-related cmdlets.

Run this script before running any other Teams management scripts.

Install-Module -Name MicrosoftTeams
Connect-MicrosoftTeams

2. List all teams in the area

This script lists all Teams in your organization.

Run this script to view a list of all Teams and check their properties.

Get-Team

3. Creating a new Team

This script creates a new Team with a specified name. Usage: Run this script whenever you want to create a new Team.

$teamName = "New Team"
New-Team -DisplayName $teamName

4. Adding a member to a Team

This script adds a user to a Team based on the username and Team ID. Run this script to add members to a specific Team.

$teamId = ""
$user = ""
Add-TeamUser -GroupId $teamId -User $user

5. Removing a member from a Team

This script removes a user from a Team based on the username and Team ID. Run this script to remove a member from a specific Team.

$teamId = ""
$user = ""
Remove-TeamUser -GroupId $teamId -User $user

6. Changing the Team name

This script changes the display name of a Team based on the Team ID. Usage: Run this script to change the name of a Team.

$teamId = ""
$newName = "New Team Name"
Set-Team -GroupId $teamId -DisplayName $newName

7. Archiving a Team

This script archives a Team based on the Team ID. Run this script to archive a Team.

$teamId = ""
Set-TeamArchivedState -GroupId $teamId -Archived $true

8. De-archiving a Team

This script de-archives a Team based on the Team ID. Run this script to restore an archived Team.

$teamId = ""
Set-TeamArchivedState -GroupId $teamId -Archived $false

9. List of all channels in a Team

This script lists all channels in a specific Team based on the Team ID. Run this script to view all channels of a particular Team and check their properties.

$teamId = ""
Get-TeamChannel -GroupId $teamId

10. Creating a new channel in a Team.

This script creates a new channel in a Team based on the Team ID and channel name. Usage: Run this script to create a new channel in an existing Team.

$teamId = ""
$channelName = "New Channel"
New-TeamChannel -GroupId $teamId -DisplayName $channelName

11. Removing a team

This script deletes a Team based on the Team ID. Usage: Run this script to completely delete a Team.

$teamId = ""
Remove-Team -GroupId $teamId

12. Removing a channel in a Team

This script removes a channel from a Team based on the Team ID and channel ID.

$teamId = ""
$channelId = ""
Remove-TeamChannel -GroupId $teamId -ChannelId $channelId

13. Changing channel name in a Team

$teamId = ""
$channelId = ""
$newName = "New Channel Name"
Set-TeamChannel -GroupId $teamId -ChannelId $channelId -DisplayName $newName

14. Retrieval of all members of a Team.

$teamId = ""
Get-TeamUser -GroupId $teamId

15. Adjusting a role of a team member

$teamId = ""
$user = ""
$role = "Owner" # or "Member"
Add-TeamUser -GroupId $teamId -User $user -Role $role

16. List of all Teams that a user is a member of.

$user = ""
Get-Team -User $user

17. Changing the description of a Team

$teamId = ""
$newDescription = "New Description"
Set-Team -GroupId $teamId -Description $newDescription

18. Creating a meeting in a channel

$teamId = ""
$channelId = ""
$startTime = "2023-04-01T10:00:00"
$endTime = "2023-04-01T11:00:00"
$subject = "Meeting Topic"
New-TeamChannelMeeting -GroupId $teamId -ChannelId $channelId -StartTime $startTime -EndTime $endTime -Subject $subject

19. Retrieving a list of apps in Teams

Get-TeamApp

20. Installing an app in a Team:

$teamId = ""
$appId = ""
Add-TeamApp -GroupId $teamId -AppId $appId
0 0 vote
Article review
Subscribe
Please let us know if there are
guest

0 Comments
Inline feedbacks
See all comments
0
Would love to know your thoughts, please leave a comment.x