Hi, We are doing a SfB to Teams Phone migration, migrating users in stages.
I’ve found a script that produces a report for Teams Policies assigned to users but it runs it against the whole tenant, includes filters to create the initial array but I want to run it against a group of users in a CSV. Can anybody tell me how I modify the script so it only runs against users listed in a csv?
Below is a portion of the script, any help is greatly appreciated.
$ModulesLoaded = Get-Module | Select-Object Name
If (!($ModulesLoaded -match "MicrosoftTeams")) {Write-Host "Please connect to the Microsoft Teams module and then restart the script"; break}
If (!($ModulesLoaded -match "ExchangeOnlineManagement")) {Write-Host "Please connect to the Exchange Online management module and then restart the script"; break}
[array]$Users = Get-CsOnlineUser -ResultSize 5000
# Filter the set to get Teams users - this will filter out all but cloud-only Teams users. If you don't want to use the filter, comment it out.
$Users = $Users | Where-Object {$_.InterpretedUserType -eq "PureOnlineTeamsOnlyUser" -or $_.InterpretedUserType -eq "PureOnlineTeamsOnlyUserFailedPublishingToAAD"} | Sort-Object DisplayName
If (!($Users)) {Write-Host "No users found - exiting"; break }
$Report = [System.Collections.Generic.List[Object]]::new()
# Process each user to fetch their policy assignments
ForEach ($User in $Users) {
$TenantDefaultString = "Tenant Default"
$TeamsMeetingPolicy = $TenantDefaultString
$TeamsMessagingPolicy = $TenantDefaultString
$TeamsAppSetupPolicy = $TenantDefaultString
$TeamsAppPermissionsPolicy = $TenantDefaultString
$TeamsEncryptionPolicy = $TenantDefaultString
$TeamsUpdatePolicy = $TenantDefaultSt