@frob ,
Get reports of external users from all site collections, do you mean this? Please check as following:
#Import SharePoint Online Management Shell
Import-Module Microsoft.Online.Sharepoint.PowerShell -DisableNameChecking
#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$ReportOutput ="C:\Temp\ExternalUsersRpt.csv"
#Get Credentials to connect
$Cred = Get-Credential
#Connect to SharePoint Online Tenant Admin
Connect-SPOService -URL $AdminSiteURL -Credential $Cred
#Get all Site Collections
$SitesCollection = Get-SPOSite -Limit ALL
$ExternalUsers=@()
#Iterate through each site collection
ForEach($Site in $SitesCollection)
{
Write-host -f Yellow "Checking Site Collection:"$Site.URL
#Get All External users of the site collection
$ExtUsers = Get-SPOUser -Limit All -Site $Site.URL | Where {$_.LoginName -like "*#ext#*" -or $_.LoginName -like "*urn:spo:guest*"}
If($ExtUsers.count -gt 0)
{
Write-host -f Green "Found $($ExtUsers.count) External User(s)!"
$ExternalUsers += $ExtUsers
}
}
#Export the Data to CSV file
$ExternalUsers | Export-Csv -Path $ReportOutput -NoTypeInformation
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.