Hi there

In this post I’m sharing a couple more powershell scripts and routines to help you out on Microsoft Teams deployment and management.

Script #1 – Export all Teams Application Setup policy report by users assigned to each policy create some policies takes time to report after they’re created. This option is not available on Teams Admin Portal at this moment. You can check by user individually (click on each user and check its policies) or click on teams app setup policy and try to add a member and that’ll show if the user you’re searching for belongs to a group or is empty.

#count
$a = (Get-CsOnlineUser -Filter {teamsappsetuppolicy -eq 'Profile3'} | Select UserPrincipalName).count
$b = (Get-CsOnlineUser -Filter {teamsappsetuppolicy -eq 'Profile1-Collab'} | Select UserPrincipalName).count
$c = (Get-CsOnlineUser -Filter {teamsappsetuppolicy -eq 'Profile2-limited'} | Select UserPrincipalName).count
$d = (Get-CsOnlineUser -Filter {teamsappsetuppolicy -eq 'App-Setup-Policy-01'} | Select UserPrincipalName).count

write-host -ForegroundColor Cyan $a "Users with Profile3"
write-host -ForegroundColor Green $b "Users with Profile1-Collab"
write-host -ForegroundColor Yellow $c "Users with Profile2-limited"
write-host -ForegroundColor magenta $d "Users with App-Setup-Policy-01"

Download this script from here.

Script #2 – export all users with Teams licensed under your Office 365 tenant based on its service plan and service name “TEAMS1”

Get-MsolUser -All | Where-Object { $_.Licenses.ServiceStatus.ServicePlan.ServiceName -match "TEAMS1"} | Select-Object UserPrincipalName, DisplayName

Script #3 – Retrieve Azure AD Group members and export to a TXT file. (you can use it in other tasks)

$group = Get-AzureADGroup -SearchString "E3-group"
$members = Get-AzureADGroupMember -ObjectId 5835c436-c1e1-496b-ab76-6b59bedd6a7c -All $true | Where-Object {$_.ObjectType -eq "User"}
$members1 = $members.userprincipalname
$members1 | Out-File all-e3-group.txt -Encoding utf8

Script #4 – Add a user to the group “E3-group” – you need the Azure AD Group ID before you run this command.

Get-AzureADGroup -SearchString "E3-group"
get-msoluser thiago_teams_test@thebeier.com Get-AzureADUser -ObjectId
Add-AzureADGroupMember -ObjectId "a4b38f3f-1478-4204-b60e-cbf683f0e00a" -RefObjectId

Script #5 – check if a user on a specific Azure AD Group has a Teams Application Setup Policy assigned to it.

$group = Get-AzureADGroup -SearchString "E3-group"
$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true | Where-Object {$_.ObjectType -eq "User"}
$members1 = $members.userprincipalname
$members1 | foreach {
$User = (Get-CsOnlineUser -Identity $_).teamsappsetuppolicy
If ($User -ne $Null) { 
write-host -ForegroundColor green "User $_ has $user policy assigned"
#$User
} Else {
write-host -ForegroundColor red "User $_ has no policy assigned"
}
}

Thanks,

Thiago Beier
TwitterLinkedInFacebookRSS