How to get the report of which all level of access each guest user has in M365 tenant via GUI or any PowerShell script?

Vinod Survase 4,756 Reputation points
2023-08-08T10:07:00.2466667+00:00

How to get the report of which all level of access each guest user has in M365 tenant via GUI or any PowerShell script?

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,730 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,200 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,347 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Emily Du-MSFT 50,006 Reputation points Microsoft Vendor
    2023-09-04T08:54:40.9266667+00:00

    For your reference, here are my external sharing reports in the SharePoint Online.

    1.Run OOTB external users report in the SharePoint site collection.User's image

    2.Audit logs.

    1

    3.PnP PowerShell.

    2


    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.

    1 person found this answer helpful.

  2. Emily Du-MSFT 50,006 Reputation points Microsoft Vendor
    2023-08-09T03:24:47.15+00:00

    Here are three methods to get external sharing report in the SharePoint.

    1.Go to a SharePoint Online site -> Click on the Settings gear -> Site usage -> Sharing with external users -> Run report.

    User's image

    2.Go to Microsoft 365 admin center -> Compliance -> Aduit -> Classic search -> Set Date and time range (Audit supports searching data within six months) -> Choose Activities like following pictures show.

    User's image

    User's image

    3.Using PnP PowerShell.

    #Parameter
    $Domain = "tenantname" 
    $CSVFile = "C:\Temp\ExternalSharing.csv"
     
    #Frame Tenant URL and Tenant Admin URL
    $TenantURL = "https://$Domain.SharePoint.com"
    $TenantAdminURL = "https://$Domain-Admin.SharePoint.com"
     
    #Delete the Output report file if exists
    If (Test-Path $CSVFile) { Remove-Item $CSVFile }
     
    #Connect to Admin Center
    Connect-PnPOnline -Url $TenantAdminURL -Interactive
        
    #Get All Site collections with External sharing enabled - Filter BOT and MySite Host
    $Sites = Get-PnPTenantSite -Filter "Url -like '$TenantURL'" | Where {$_.SharingCapability -ne "Disabled"}
       
    #Iterate through all site collections
    $Sites | ForEach-Object {
        Write-host "Getting External Users of Site:"$_.URL -f Yellow
        #Connect to each site collection
        Connect-PnPOnline -Url $_.URL -Interactive
        $ExternalUsersData = @()
     
        #Get all External Users of the site collection
        $ExternalUsers = Get-PnPUser | Where {$_.LoginName -like "*#ext#*" -or $_.LoginName -like "*urn:spo:guest*"}   
        Write-host "`tFound '$($ExternalUsers.count)' External users" -f Green
         
        #Collect Data
        ForEach($User in $ExternalUsers)
        {
            $ExternalUsersData += New-Object PSObject -Property ([ordered]@{
                SiteName = $_.Title
                SiteURL  = $_.URL
                UserName = $User.Title
                Email = $User.Email
            })
        }
     
        #Export Documents Inventory to CSV
        $ExternalUsersData | Export-CSV $CSVFile -NoTypeInformation -Append
    }
     
    Write-host "External Users Report Generated Successfully!" -f Magenta
    

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.