question

QuinqueXavier-3419 avatar image
0 Votes"
QuinqueXavier-3419 asked ·

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

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

office-teams-windows-itpro
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SharonZhao-MSFT avatar image
0 Votes"
SharonZhao-MSFT answered ·

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 (  
            $ExportPath
            )  
     process{
                 Connect-PnPOnline -Scopes "Group.Read.All","User.ReadBasic.All"
                 $accesstoken =Get-PnPAccessToken
                 $MTeams = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri  "https://graph.microsoft.com/beta/groups?`$filter=resourceProvisioningOptions/any(c:c+eq+`'Team`')" -Method Get
                 $TeamsList = @()
                 $i=1
                 do
                 {
                     foreach($value in $MTeams.value)
                     {
           
                             Write-Progress -Activity "Get All Teams" -status "Found Team $i"                
                      
                             $id= $value.id
                             Try
                             {
                                 $team = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/beta/Groups/$id/channels -Method Get
                                    
                             }
                             Catch
                             {
                                   
                             }                 
                    
                             $Owner = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/v1.0/Groups/$id/owners -Method Get
                             $Members = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri https://graph.microsoft.com/v1.0/Groups/$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
                             $teamaccesstype=$null
                             $errorMessage =$null
                             $Teams=$null
                             $team =$null
                             $i++
                     }
                     if ($MTeams.'@odata.nextLink' -eq $null )
                     {
                         break
                     }
                     else
                     {
                         $MTeams = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} -Uri $MTeams.'@odata.nextLink' -Method Get
                     }
                 }while($true);
                 $TeamsList.count
                 $TeamsList
                 $TeamsList | Export-csv $ExportPath -NoTypeInformation
             }
 }
 Export-TeamsList -ExportPath "C:\temp\teamswithmembers.csv"



· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.