Filip Kasaj

I can act how I want, but I can't want what I want.

User Tools

Site Tools


technet:msgraph:externaluserreport

Reporting SharePoint Online External Users with PowerShell

SharePoint external user is someone who doesn’t have an account in your tenant. Because of the influence of Teams, most SharePoint Online external users are guest accounts, created when external people join the membership of Microsoft 365 Groups (teams). If the organization uses the SharePoint Online integration with Azure AD B2B collaboration, SharePoint also creates guest accounts when people share files or folders with external people…https://office365itpros.com/2022/07/20/sharepoint-external-users-report/?utm_source=rss&utm_medium=rss&utm_campaign=sharepoint-external-users-report

  1. $Sites = Get-SPOSite -Limit All | Sort-Object Title
  2. $ExternalSPOUsers = [System.Collections.Generic.List[Object]]::new()
  3. #Iterate through each site and retrieve external users
  4. $Counter = 0
  5. ForEach ($Site in $Sites) {
  6. $Counter++
  7. Write-Host ("Checking Site {0}/{1}: {2}" -f $Counter, $Sites.Count, $Site.Title)
  8. [array]$SiteUsers = $Null
  9. $i = 0; $Done = $False
  10. Do {
  11. [array]$SUsers = Get-SPOExternalUser -SiteUrl $Site.Url -PageSize 50 -Position $i
  12. If ($SUsers) {
  13. $i = $i + 50
  14. $SiteUsers = $SiteUsers + $SUsers }
  15. If ($SUsers.Count -lt 50) {$Done = $True}
  16. } While ($Done -eq $False)
  17. ForEach ($User in $SiteUsers) {
  18. $ReportLine = [PSCustomObject] @{
  19. Email = $User.Email
  20. Name = $User.DisplayName
  21. Accepted = $User.AcceptedAs
  22. Created = $User.WhenCreated
  23. SPOUrl = $Site.Url
  24. TeamsChannel = $Site.IsTeamsChannelConnected
  25. ChannelType = $Site.TeamsChannelType
  26. CrossTenant = $User.IsCrossTenant
  27. LoginName = $User.LoginName }
  28. $ExternalSPOUsers.Add($ReportLine) }
  29. } #End ForEach Site
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
technet/msgraph/externaluserreport.txt · Last modified: 2023/06/14 09:40 by fk