Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PowerShell script to retrieve external users that have been added via modern sharing experience on files and folders (with verification code to email). These users are not retrieved with Get-SPOExternalUser and not present in Azure AD.
<#
Script to retrieve external users that have been added via modern sharing experience on files and folders (with verification code to email).
These users are not retrieved with Get-SPOExternalUser cmdlet and not added as guest users in Azure AD.
Requires: SharePoint Online Management Shell > https://www.microsoft.com/en-us/download/details.aspx?id=35588
#>
Connect-SPOService -Url https://<tenantName>-admin.sharepoint.com
Get-SPOSite -Limit All | ForEach-Object {
if (($_.SharingCapability -ne "Disabled") -and ($_.SharingCapability -ne "ExistingExternalUserSharingOnly")) {
$url = $_.Url
Get-SPOUser -Site $url -Limit All | Where-Object -Property LoginName -match guest | Select-Object -Property @{n="Url"; e={$url}}, DisplayName, LoginName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.