• Home
  • BLOGS

Menu
  • Home
  • BLOGS
06 August 2020

Query all MS Teams and Export list of guests added to each Team site

Written by Ryan Wilson
# Connecting to Teams
Connect-MicrosoftTeams

# Connecting to Azure AD
Connect-AzureAD

#Get list of all Teams
$AllTeams = get-team

# For each team extract members
foreach ($team in $AllTeams)
{
  $groupmembers = Get-AzureADGroupMember -ObjectId $team.groupid
  foreach ($member in $groupmembers)
  {
    $array=[ordered]@{
     	"Group ID"=$team.groupid;
     	"Group Name"=$team.DisplayName;
     	"Guest Name"=$member.DisplayName;
     	"Email Address"=$member.mail;
	"Type"=$member.UserType;
  }
  If ( $member.UserType -eq 'Guest')  {
    $obj=New-Object -TypeName psobject -Property $array
    Export-Csv -path "c:\temp\TeamsGuests.csv" -InputObject $obj -Append -NoTypeInformation
  }
}
}

Leave a Reply

Cancel reply

Recent Posts

  • MS Teams – export team owners
  • Deploy AppLocker in Intune- Block CMD and PowerShell
  • Autopilot Hybrid Joined device built outside the corporate network
  • Add a SharePoint site as a custom app within Teams
  • Query all MS Teams and Export list of guests added to each Team site
  • MS Flow – adding timestamp in the middle of a filename whilst retaining file extension
  • MS Flow to export outlook attachment into a Teams channel and notify users with an adaptive card
  • Unlicense Office suite using last 5 characters
  • Azure Information Protection – We were not able to find the Information Rights Management template.
  • Intune – Chrome homepage remediation failed Error: 0x87d1fde8

Recent Comments

  • Ged on MS Flow to export outlook attachment into a Teams channel and notify users with an adaptive card
  • film on Autopilot Hybrid Joined device built outside the corporate network
  • Ryan Wilson on Azure Information Protection – We were not able to find the Information Rights Management template.
  • BurtonMBrohl on Azure Information Protection – We were not able to find the Information Rights Management template.
  • Ryan Wilson on Azure Information Protection – We were not able to find the Information Rights Management template.
  • RayeXDuesing on Azure Information Protection – We were not able to find the Information Rights Management template.
  • TroyTHulette on Azure Information Protection – We were not able to find the Information Rights Management template.
  • NildaZAdamos on Azure Information Protection – We were not able to find the Information Rights Management template.
  • Ryan Wilson on Azure Information Protection – We were not able to find the Information Rights Management template.
  • NoahVSolak on Azure Information Protection – We were not able to find the Information Rights Management template.

Archives

  • December 2020
  • November 2020
  • October 2020
  • August 2020
  • June 2020
  • May 2020
  • February 2020
  • January 2020
  • December 2019
  • July 2019

Categories

  • IT Blogs (19)
© Copyright 2017. Theme by BloomPixel.