Teams PowerShell
The MicrosoftTeams module covers Teams and the voice and policy cmdlets that used to live in Skype for Business Online.
Documentation: Microsoft Learn
Overview
The structural thing to know is that every team is backed by a Microsoft 365 group. GroupId is the join key, and it is how you connect Get-Team results to Graph group data. Team membership is group membership, so the same membership can be reached from either side, and changes from one show up in the other.
The cmdlet naming is split. Get-Team, Get-TeamUser and Get-TeamChannel manage teams. The Cs-prefixed cmdlets, Get-CsTeamsMeetingPolicy, Get-CsOnlineUser and the rest, come from the Skype for Business lineage and cover policy, calling and meetings. Two naming conventions in one module is confusing until you know why.
Get-CsOnlineUser is the one to reach for on voice and policy assignment questions, and it returns different information from Get-MgUser for the same person.
Policies are assigned per user with Grant-CsTeamsMeetingPolicy, and the assignment can take time to take effect. A change that appears not to have worked has often just not propagated yet, so check again before changing it twice.
The module changes fairly often. Pin a version in automation rather than always taking the latest.
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
[pscustomobject]@{
Connect = 'Connect-MicrosoftTeams'
Teams = 'Get-Team | Select-Object DisplayName, Visibility, GroupId'
Users = 'Get-TeamUser -GroupId <id> | Select-Object User, Role'
Policy = 'Get-CsTeamsMeetingPolicy | Select-Object Identity, AllowCloudRecording'
} | Format-List- Stage 1[pscustomobject]@{
Positional values or no named parameters - Stage 2Format-List
Positional values or no named parameters
An example to inspect
Preview the example. Sign in for the full lesson and activities.
[pscustomobject]@{
Connect = 'Connect-MicrosoftTeams'
Teams = 'Get-Team | Select-Object DisplayName, Visibility, GroupId'
Users = 'Get-TeamUser -GroupId <id> | Select-Object User, Role'
Policy = 'Get-CsTeamsMeetingPolicy | Select-Object Identity, AllowCloudRecording'
} | Format-ListWhat happens
This prints the four commands. Note GroupId in the Teams line: keeping it in your output is what lets you join Teams results to Graph group queries later. The last line shows a Cs-prefixed policy cmdlet next to the Team ones, which is the naming split made visible.
Worth remembering
- Every team is backed by a Microsoft 365 group; GroupId is the join key.
- Team cmdlets and Cs-prefixed policy cmdlets live in the same module.
- Get-CsOnlineUser covers voice and policy, unlike Get-MgUser.
- Policy assignments take time to propagate. Pin the module version.
Primary documentation
Try it
Expected output · prints command text; does not execute these commands
Example reader
Inspect this page's example
Run supported commands against the practice data, or inspect the example without executing it.
Ready to inspect.
Prints Teams queries including the group id used to join to Graph.
Show reference output
Expected output · prints command text; does not execute these commands
Connect : Connect-MicrosoftTeams Teams : Get-Team | Select-Object DisplayName, Visibility, GroupId Users : Get-TeamUser -GroupId <id> | Select-Object User, Role Policy : Get-CsTeamsMeetingPolicy | Select-Object Identity, AllowCloudRecording
Keep going
Next: Azure PowerShellCheck your understanding
You connected successfully but a Teams command is denied. What does that tell you?
Authentication succeeded; the operation may still require a different role or permission. Check the exact error and account role.