How to export from shift (teams) the member email addresses in addition to name

asked 2020-06-05T09:47:58.197+00:00
Quinque Xavier 1 Reputation point

In export I only have the name of the member, I also want to have his login, email ..
Thank you

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
5,271 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2020-06-08T02:51:20+00:00
    Sharon Zhao-MSFT 24,651 Reputation points Microsoft Employee

    Hi QuinqueXavier-3419,

    When you create a schedule in Shifts, the members are consistent with the team which you chosen.

    You can export the members’ properties of each team by the following script. To run this script, you need to have installed SharePoint Online PnP module. You can get this from here.

    function Export-TeamsList  
         param (    
                    Connect-PnPOnline -Scopes "Group.Read.All","User.ReadBasic.All"  
                    $accesstoken =Get-PnPAccessToken  
                    $MTeams = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri  "`$filter=resourceProvisioningOptions/any(c:c+eq+`'Team`')" -Method Get  
                    $TeamsList = @()  
                        foreach($value in $MTeams.value)  
                                Write-Progress -Activity "Get All Teams" -status "Found Team $i"                  
                                $id= $  
                                    $team = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri$id/channels -Method Get  
                                $Owner = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri$id/owners -Method Get  
                                $Members = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri$id/Members -Method Get  
                                $Teams = "" | Select "TeamsName","Owners","MembersCount","Members","MembersEmail"  
                                $Teams.TeamsName = $value.displayname  
                                $Teams.Owners = $Owner.value.displayName -join ";"  
                                $Teams.MembersCount = $Members.value.userPrincipalName.count  
                                $Teams.Members = $Members.value.displayName -join ";"  
                                $Teams.MembersEmail = $Members.value.mail -join ";"  
                                $TeamsList+= $Teams  
                                $errorMessage =$null  
                                $team =$null  
                        if ($MTeams.'@odata.nextLink' -eq $null )  
                            $MTeams = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri $MTeams.'@odata.nextLink' -Method Get  
                    $TeamsList | Export-csv $ExportPath -NoTypeInformation  
    Export-TeamsList -ExportPath "C:\temp\teamswithmembers.csv"  
    No comments