Skip to content

Instantly share code, notes, and snippets.

@jcallaghan
Created July 9, 2020 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcallaghan/bce528ed741330b315934908e6be35ca to your computer and use it in GitHub Desktop.
Save jcallaghan/bce528ed741330b315934908e6be35ca to your computer and use it in GitHub Desktop.
# Created by SAMCOS @ MSFT, Collaboration with others!
## You must first connect to Microsoft Teams Powershell & Exchange Online Powershell for this to work.
## Links:
## Teams: https://www.powershellgallery.com/packages/MicrosoftTeams/1.0.0
## Exchange: https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps
## Have fun! Let me know if you have any comments or asks!
$AllTeamsInOrg = (Get-Team).GroupID
$TeamList = @()
Write-Output "This may take a little bit of time... Please sit back, relax and enjoy some GIFs inside of Teams!"
Write-Host ""
Foreach ($Team in $AllTeamsInOrg)
{
$TeamGUID = $Team.ToString()
$TeamGroup = Get-UnifiedGroup -identity $Team.ToString()
$TeamName = (Get-Team | ?{$_.GroupID -eq $Team}).DisplayName
$TeamOwner = (Get-TeamUser -GroupId $Team | ?{$_.Role -eq 'Owner'}).User
$TeamUserCount = ((Get-TeamUser -GroupId $Team).UserID).Count
$TeamCreationDate = Get-unifiedGroup -identity $team.ToString() | Select -expandproperty WhenCreatedUTC
$TeamGuest = (Get-UnifiedGroupLinks -LinkType Members -identity $Team | ?{$_.Name -match "#EXT#"}).Name
if ($TeamGuest -eq $null)
{
$TeamGuest = "No Guests in Team"
}
$TeamList = $TeamList + [PSCustomObject]@{TeamName = $TeamName; TeamObjectID = $TeamGUID; TeamCreationDate = $TeamCreationDate; TeamOwners = $TeamOwner -join ', '; TeamMemberCount = $TeamUserCount; TeamSite = $TeamGroup.SharePointSiteURL; AccessType = $TeamGroup.AccessType; TeamGuests = $TeamGuest -join ','}
}
#######
$TestPath = test-path -path 'c:\temp'
if ($TestPath -ne $true) {New-Item -ItemType directory -Path 'c:\temp' | Out-Null
write-Host 'Creating directory to write file to c:\temp. Your file is uploaded as TeamsDatav2.csv'}
else {Write-Host "Your file has been uploaded to c:\temp as 'TeamsDatav2.csv'"}
$TeamList | export-csv c:\temp\TeamsDatav2.csv -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment