Published: 28.Jun 2021
Categories:

How to check "Teams Coexistence Mode" for list of users via PowerShell

You will need MicrosoftTeams module for this.
Output is CSV file, which will be saved on your desktop - usersTeamsMode.csv

Param(
    [Parameter(Mandatory=$false,
    ValueFromPipeline=$true)]
    [String[]]
    $csvPath
)

# Check if Teams module is imported
$module = (Get-Module).Name

if ($module -contains "microsoftteams")
{
    Write-Host "Teams module is already loaded, continuing.." -ForegroundColor Green
}
else
{
    Write-Host "Loading MS Teams module.." -ForegroundColor Yellow
    Import-Module MicrosoftTeams    
}

if ($null -eq $csvPath)
{
    Write-Host "Enter path to CSV file (Header should be UPN):" -ForegroundColor Cyan
    $csvPath = Read-Host
}

# Import users
$script:Users = Import-CSV -Path $csvPath
Write-Host $($Users).count " users were loaded.." -ForegroundColor Yellow

# Check users
$data = foreach ($u in $Users)
{
    Write-Host "Checking user: "$u.UPN
    # Get Teams Mode Value
    $tMode = Get-CsOnlineUser -identity $u.UPN | Select-Object TeamsUpgradeEffectiveMode

    $teamsMode = $tMode.TeamsUpgradeEffectiveMode

    if ($null -eq $teamsMode)
    {
        $teamsMode = "none"
    }

    # Prepare custom object for export
    [PSCustomObject]@{
        ID = $u.UPN
        TeamsMode = $teamsMode
    }
}

# Export data to CSV file
$data | Export-CSV -path $env:USERPROFILE\Desktop\usersTeamsMode.csv -NoTypeInformation

Write-Host "Script finished, you will find CSV report on your desktop - usersTeamsMode.csv" -ForegroundColor Green

0 0 votes
Article Rating
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Nick Clements
Nick Clements
1 month ago

Is the csv we import just to be one column with their UPN or should it be two columns with Users,UPN? Or more?

PowerAddict.net - Lubomir Goban  ---  Find me on - 
LinkedIn
2
0
Would love your thoughts, please comment.x
()
x