PowerAddict.net

powerAddict.NET

by Lou Goban
IT Application Professional at Syntax

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

2 comments

  • Nick Clements

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

    • A
      PowerAddict

      It should be only the UPN of the users.
      So header of the CSV file will start with UPN and then upn of the user of each line.

Leave your comment