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
$Sites = Get-SPOSite -Limit All | Sort-Object Title $ExternalSPOUsers = [System.Collections.Generic.List[Object]]::new() #Iterate through each site and retrieve external users $Counter = 0 ForEach ($Site in $Sites) { $Counter++ Write-Host ("Checking Site {0}/{1}: {2}" -f $Counter, $Sites.Count, $Site.Title) [array]$SiteUsers = $Null $i = 0; $Done = $False Do { [array]$SUsers = Get-SPOExternalUser -SiteUrl $Site.Url -PageSize 50 -Position $i If ($SUsers) { $i = $i + 50 $SiteUsers = $SiteUsers + $SUsers } If ($SUsers.Count -lt 50) {$Done = $True} } While ($Done -eq $False) ForEach ($User in $SiteUsers) { $ReportLine = [PSCustomObject] @{ Email = $User.Email Name = $User.DisplayName Accepted = $User.AcceptedAs Created = $User.WhenCreated SPOUrl = $Site.Url TeamsChannel = $Site.IsTeamsChannelConnected ChannelType = $Site.TeamsChannelType CrossTenant = $User.IsCrossTenant LoginName = $User.LoginName } $ExternalSPOUsers.Add($ReportLine) } } #End ForEach Site
technet/msgraph/externaluserreport.txt · Last modified: 2023/06/14 09:40 by fk