Jun 29 2023 04:49 AM
With a PowerShell script, the following information should be stored in a csv file:
- Team name
- Teams channels
- Team members
- Teams owner
- All files in a team channel incl. owner and with whom this file was shared
Is especially the last point possible to implement? who can help?
Jun 30 2023 10:08 PM - edited Jun 30 2023 11:18 PM
Hi, @Melina you can use the below Graph PowerShell script to read teams information to satisfy your needs.
$teams = Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')"
foreach ($team in $teams){$teamName = $team.DisplayName
$teamId = $team.Id
Write-Host "Team Name: $teamName"
$GroupOwner = get-mggroupowner -GroupId $teamId| Select AdditionalProperties
$hashtable = $GroupOwner.AdditionalProperties
Write-Host "Team Owner: $($hashtable.displayName) `n"
$channels = Get-MgTeamChannel -TeamId $teamId
foreach ($channel in $channels) {$channelName = $channel.DisplayName
Write-Host "Channel Name: $channelName `n"
$members = Get-MgTeamChannelMember -TeamId $teamId -ChannelId $channel.Id
foreach ($member in $members) {
Write-Host "Member: $($member.DisplayName)"
}
$messages = Get-MgTeamChannelMessage -TeamId $TeamId -ChannelId $channel.Id
foreach ($message in $messages) {
foreach ($attachment in $message.Attachments) {
$fileName = $attachment.Name
$user = Get-MgUser -UserId $message.From.User.Id
Write-Host "File Name: $fileName"
Write-Host "Sent by: $($user.DisplayName) `n"
}
}
}Write-Host "`n`n"
}
Further more, to get additional information on creating new team, modifying teams, managing channels and more using Graph PowerShell, refer the following blog: https://m365scripts.com/microsoft-teams/top-10-cmdlets-to-manage-teams-using-microsoft-graph-powersh...
Jul 04 2023 06:54 AM
@Thiraviam5316thank you!
I am facing the next challenge:
Can you help me further, which role or settings are necessary besides Global Admin? And where these roles must be assigned?
Jul 05 2023 03:29 AM - edited Jul 05 2023 03:30 AM
@Melina You must connect to the Microsoft Graph PowerShell with the required scopes for accessing the channel member: ChannelMember.Read.All, ChannelMember.ReadWrite.All
For eg,
Connect-MgGraph -Scopes "ChannelMember.Read.All, ChannelMember.ReadWrite.All"
After Connecting to the Graph PowerShell, you can run the script to get the Teams report.