One of our clients recently came to us with a clear—but tricky—requirement:
➡️ “We need a list of all external users across our SharePoint tenant, along with who invited them and when they were invited.”
✅ Using a third-party tool wasn’t an option due to internal compliance policies.
🚫 Microsoft doesn’t provide a direct, out-of-the-box way in the SharePoint admin center to export this level of detail across all sites.
So what did we do?
We built a lightweight but effective PowerShell script to get the job done.
Loops through all SharePoint Online sites in the tenant
For each site, it identifies external users (guests)
Extracts useful info like email, display name, who invited them, and the invitation date
Then exports the final result to a clean CSV file for easy auditing and reporting
💡 While simple, this script saved the client hours of manual work and gave them clear visibility into their external sharing posture.
🔧 No third-party tools, no complex deployments—just native PowerShell and Microsoft 365 modules.
📥 Want the script? Drop a comment or message me and I’ll be happy to share it.
#Import SharePoint Online Management Shell Import-Module Microsoft.Online.Sharepoint.PowerShell -DisableNameChecking #Config Parameters $AdminSiteURL="https://[YOURTENANT]-admin.sharepoint.com" $ReportOutput ="C:\Temp\ExternalUsersRpt_AllSites.csv" #Connect to SharePoint Online Tenant Admin Connect-SPOService -URL $AdminSiteURL #Get All Site Collections $SiteCollections = Get-SPOSite -Limit All #Iterate through each site collection and get external users Foreach ($Site in $SiteCollections) { Write-host -f Yellow "Checking Site Collection:"$Site.URL Try { For ($x=0;;$x+=50) { $ExternalUsers += Get-SPOExternalUser -SiteUrl $Site.Url -Position $x -PageSize 50 -ErrorAction Stop | Select DisplayName,EMail,InvitedBy,AcceptedAs,WhenCreated,@{Name = "SiteUrl" ; Expression = {$Site.url} } } } catch {} } #Export the Data to CSV file $ExternalUsers | Export-Csv -Path $ReportOutput -NoTypeInformation
#PowerShell #SharePoint #Microsoft365 #Governance #ExternalUsers #M365Security #SharePointOnline #Logisam #PowerPlatform #MVPBuzz