Efficiently Manage Microsoft Teams Users Using PowerShell

Efficiently Manage Microsoft Teams Users Using PowerShell

As we all know, the Microsoft Teams app is specifically designed to facilitate real-time collaboration, seamless communication, interactive virtual meetings, and efficient file sharing among users. Given these functionalities, managing Microsoft Teams becomes crucial for ensuring smooth collaboration. Apart from managing it, there is an essential need to manage Microsoft Teams users because it is primarily intended for user communication.

For MS Teams membership management, admins can use both the Teams admin center and PowerShell. Although the Teams admin center provides a user-friendly interface, it lacks features such as bulk operations, speed, automation, etc.

As an eye-opener, this blog will guide you through the effective operations required for Microsoft Teams members management using PowerShell.

Manage MS Teams Members Using PowerShell

Admins can effectively perform the Microsoft Teams membership management using PowerShell with the following major operations. Prior to the commencement of utilizing the cmdlets, make sure to connect to the Microsoft Teams PowerShell module.

Add Users to Teams Using PowerShell

Admins can use the “Add-TeamUser” cmdlet with the required parameters as described below to add the users to a Microsoft Team.

Add-TeamUser -GroupId <GroupId> -User <UPN>

Replace the <GroupId> with the group Id of the respective Team and <UPN> with the user’s or guest’s user principal name.

Note: Teams group Id can be easily retrieved with the help of the “Get-Team” cmdlet.

You can upgrade a user from user to owner by executing the above cmdlet along with the “Role” parameter.

Add-TeamUser -GroupId <GroupId> -User <UPN> -Role Owner

To add bulk users to the Team, create a CSV file with the list of users’ UPN as shown below. After creation, run the cmdlet with the CSV file location and the group Id.

Add Bulk Users to Teams Using PowerShell - CSV Format

Import-Csv <FileLocation>| ForEach {Add-TeamUser -GroupId <GroupId> -User $_.UPN}

Remove Users from Teams with PowerShell

The “Remove-TeamUser” cmdlet can remove users from Microsoft Teams or demote the owners of the Team to members. To remove the owners from a Team, first demote them to members, then remove them.

Remove-TeamUser –GroupId <GroupId> -User <OwnerUPN> -Role Owner

This cmdlet demotes the specified owner to a member of the respective Team. Replace <OwnerUPN> with the UPN of the owner to be demoted.

Remove-TeamUser –GroupId <GroupId> -User <UPN>

This cmdlet removes the specified member or owner from the respective Team. Replace <MemberUPN> with the UPN of the member to be removed.

To gain insights into users who have been added and removed from all the Teams in the organization, administrators can depend on the audit Team membership changes report. This report offers information about users who have been added, removed, and any role changes that have taken place.

Get List of Teams Users Using PowerShell

The users (Owners/Members) available in the particular Teams group can be retrieved using the following cmdlet.

Get-TeamUser -GroupId <GroupId>

Replace the <GroupId> with the appropriate group Id.

Get all users in Teams with PowerShell

In addition to this, admins can also get the list of all Teams where a user is a member with the help of PowerShell. For a more comprehensive view of Teams membership with various customizations, Microsoft Teams reporting offers admins access to 8 advanced, well-formatted reports.

Add Users to Private Channel in Teams with PowerShell

Normally, users added to Teams can access all the channels except the private channels. Admins can manage Microsoft Teams private channels by adding users to them using the cmdlet below.

Add-TeamChannelUser –GroupId <GroupId> -DisplayName <PrivateChannelName> -User <UPN>

Replace the <GroupId> with the group Id of the respective Team, <UPN> with the user’s principal name, and <PrivateChannelName> with the appropriate channel name.

Note: Running the cmdlets might not immediately reflect the update in the Teams application. To see the changes, just refresh the channel’s members page.

To make Team users as owner of the private channel include the “Role” parameter with the “Owner” attribute in the above cmdlet.

Add-TeamChannelUser –GroupId <GroupId> -DisplayName <PrivateChannelName> -User <UPN> -Role Owner

Admins can add bulk users to the private channel by creating a CSV file with the list of users’ UPNs. After creation, execute the cmdlet with the CSV file location, group Id, and private channel name.

Import-Csv <FileLocation>| ForEach {Add-TeamChannelUser –GroupId <GroupId> -DisplayName <PrivateChannelName> -User $_.UPN} 

Point to remember: Admins can only add members to Private Channels who are already part of that team.

Remove Users from Private Channel Using PowerShell

The “Remove-TeamChannelUser“ cmdlet can remove a user from the private channel or demote the owner into a member.

Remove-TeamChannelUser –GroupId <GroupId> -User <OwnerUPN> -DisplayName <PrivateChannelName> -Role Owner

This cmdlet demotes the specified owner to a member in the respective private channel of the Team. Replace <OwnerUPN> with the UPN of the owner to be demoted.

Remove-TeamChannelUser –GroupId <GroupId> -User <MemberUPN> -DisplayName <PrivateChannelName>

This cmdlet removes the specified member from the respective private channel of the Team. Replace <MemberUPN> with the UPN of the member to be removed.

Get Teams Private Channel Members with PowerShell

To retrieve and list all the users present in the Microsoft Teams private channel, utilize the cmdlet below.

Get-TeamChannelUser –GroupId <GroupId> -DisplayName <PrivateChannelName>

Replace the <GroupId> with the group Id of the respective Team and <PrivateChannelName> with the appropriate channel name. By combining the PowerShell cmdlets “Get-TeamChannel ” and “Get-TeamChannelUser ” with foreach loop, you can export all private channels’ members details.

Get Teams Private Channel Members with PowerShell

Add External Users to Microsoft Teams Shared Channels

After configuring the B2B direct connect settings, Microsoft Teams admins can utilize PowerShell cmdlet to add external users to Teams shared channels.

Add-TeamChannelUser -GroupId <GroupId> -DisplayName <SharedChannelName> -User <EXTUserUPN> -TenantId <EXTTenantId>

Note: Adding internal organization users to shared channels is similar to adding users to private channels

Retrieve Shared Channel Members Using PowerShell

Just like listing the private channel members or owners, you can easily retrieve the users in the shared channel with the same cmdlet. Input the shared channel name in the display name parameter to get the user details of the MS Teams shared channel.

Get-TeamChannelUser –GroupId <GroupId> -DisplayName <SharedChannelName>

Retrieve shared channel users using PowerShell

We all know that a shared channel can also be shared with other Teams. To view the Teams with which the shared channel is shared, use the cmdlet “Get-SharedWithTeam“.

Get-SharedWithTeam -HostTeamId <HostTeamGroupId> -ChannelId <SharedChannelId>

Replace <HostTeamGroupId> with the group Id of the Team that is hosting the shared channel (Team in which the shared channel is created), and <SharedChannelId> with the Id of the shared channel that is shared among Teams.

Teams with which shared channel is shared

To retrieve the users of the Team with which the specified channel is shared, execute the following cmdlet.

Get-SharedWithTeamUser -HostTeamId <HostTeamGroupId> -ChannelId <SharedChannelId> -SharedWithTeam <AccessingTeamId>

Replace <AccessingTeamId> with the Team Id of the other team with which the shared channel is already shared.

Users of a team with which a specified channel is shared

To retrieve only the owners of the Team with which the specified shared channel is shared, execute the same cmdlet with the “Role” parameter.

Get-SharedWithTeamUser -HostTeamId <HostTeamGroupId> -ChannelId <SharedChannelId> -SharedWithTeam <AccessingTeamId> -Role Owner

For a detailed analysis, admins can export MS Teams shared channel members by utilizing the power of PowerShell scripting.

Manage Microsoft Teams Call Settings for Users with PowerShell

PowerShell can also be used to manage and configure MS Teams users’ call forwarding and delegation settings. MS Teams admin can retrieve and configure the call settings using the “Get-CsUserCallingSettings“ and “Set-CsUserCallingSettings” cmdlets. Below is the list of operations that are related to Teams call settings using PowerShell.

List Call Forwarding and Delegation Settings for a Teams User

The below cmdlet retrieves the Teams call forwarding settings configured for a respective user.

Get-CsUserCallingSettings -Identity <UPN>

Get Teams user calling settings with PowerShell

To fetch the permissions of delegated users who can access a specific Teams user’s calls, expand the delegate property as detailed below.

(Get-CsUserCallingSettings -Identity <UPN>).Delegates

Permissions of delegated users who can access a specific Teams user's calls

Configure Call Forwarding Settings for a Teams User with PowerShell

The Teams call forwarding settings can be configured for Microsoft Teams users using the following cmdlets with different operations.

Warning: There is no cmdlet to remove the configured call forwarding setting, so carefully configure the settings. If a setting is wrongly configured, it can be reverted using the MS Teams client.

Set-CsUserCallingSettings -Identity [email protected] -IsForwardingEnabled $true -ForwardingType Immediate -ForwardingTargetType SingleTarget -ForwardingTarget [email protected]

Execution of the above cmdlet forwards all the incoming calls of Sam to Jabez.

Set-CsUserCallingSettings -Identity [email protected] -IsForwardingEnabled $true -ForwardingType Simultaneous -ForwardingTargetType SingleTarget -ForwardingTarget [email protected]

To make the incoming calls ring for Sam and Jabez simultaneously, execution of this cmdlet can help.

Set-CsUserCallingSettings -Identity [email protected] -IsForwardingEnabled $true -ForwardingType Simultaneous -ForwardingTargetType MyDelegates

This cmdlet makes all the incoming calls ring for Sam and all the delegated users.

$CallGroup = @("[email protected]","[email protected]") 

Set-CsUserCallingSettings -Identity [email protected] -CallGroupOrder InOrder -CallGroupTargets $CallGroup 

Set-CsUserCallingSettings -Identity [email protected] -IsForwardingEnabled $true -ForwardingType Immediate -ForwardingTargetType Group 

The brief script above forms a group consisting of two users, Jill and Jack, and then configures Sam’s call-forwarding settings to route calls to this newly created group.

Set Up Delegates to Manage Calls in Microsoft Teams

The “New-CsUserCallingDelegatecmdlet can be used to add a new delegated user to receive, make, and manage Teams calls on behalf of any user.

New-CsUserCallingDelegate -Identity [email protected] -Delegate [email protected] -MakeCalls $true -ReceiveCalls $true -ManageSettings $true

The above cmdlet allows Sam to make, receive, and manage MS Teams calls on behalf of Jency. You can input either true or false in the selective parameters concerning the need for delegation.

Update Delegated Calls Permission in MS Teams Using PowerShell

After adding delegates to manage Teams call settings, you can update the permissions to the user-preferred one whenever it is needed.

Set-CsUserCallingDelegate -Identity [email protected] -Delegate [email protected] -MakeCalls $false -ReceiveCalls $true -ManageSettings $true

This command will set the delegate calling settings for the user Sam by allowing them to receive calls, and manage settings, but not make calls on behalf of Jency.

Remove Delegated Calling Permission in MS Teams Using PowerShell

Admins can remove the setting configured for the delegation of calls in Microsoft Teams using “Remove-CsUserCallingDelegatecmdlet.

Remove-CsUserCallingDelegate -Identity [email protected] -Delegate [email protected] 

This single-line cmdlet removes the delegated permission configured to Sam for Jency’s Teams calls.

Hassle-Free Microsoft Teams User Management Using AdminDroid!

For effective management of members in Microsoft Teams, there is an essential need to monitor its configurations. The process of monitoring Microsoft Teams members can be simplified further, eliminating the necessity for specific cmdlets. AdminDroid’s Microsoft Teams Membership Reports provide comprehensive insights into user details, conveniently sliced and diced!

In addition to the membership reports, AdminDroid’s Microsoft Teams reporting provides a 360-degree overview of the Teams configurations through the following report collections.

  • Microsoft Teams Overview Reports
  • Standard, Private, and Private Channel Reports
  • Microsoft Teams Usage Statistics
  • MS Teams Inactive Users Reports
  • Teams Setting and Permission Reports
  • Daily Summary and Device Usage Reports
  • Teams Meeting Activities Reports

MS Teams Membership Report - AdminDroid

Also, admins can view the audit changes using the Microsoft Teams auditing tool without relying on PowerShell scripts or cmdlets to efficiently track all the activities. Some of the activities include Teams’ logins, Teams settings and permissions, Teams membership changes, ownership promotions, etc.

Moreover, the Teams dashboard gallery provided by AdminDroid gives a holistic bird’s eye view of MS Teams and its usage.

Microsoft Teams Dashboard Gallery - AdminDroid

The AdminDroid’s Teams management tool covers 110+ inclusive reports with advanced AI graphics and vivid graphs. This enhanced UI feature can free the admins from dealing with cumbersome PowerShell reports.

AdminDroid Office 365 reporting tool extends its coverage beyond Microsoft Teams, offering extensive insights into all M365 services, including Azure AD, Exchange, SharePoint, Viva Engage, Power BI, and more.

Explore the potential of AdminDroid and experience its premium features in your M365 tenant FREE for 15 daysNo Card Details Needed!

We hope that this blog has provided you with the required information needed for the Microsoft Teams users management using PowerShell. If you have any queries regarding the blog, please feel free to leave your valuable comments below.

Efficiently Manage Microsoft Teams Users Using PowerShell

by Thiraviam time to read: 9 min
0