Guest access expiration report for SharePoint Online site?

Prakash Kumar Singh 40 Reputation points
2024-11-14T18:13:51.1166667+00:00

Hi,

In my tenant, Guest access expiration is set for 180 days.

I need to generate report for a SPO site that how many guests' users already lost access and how many guest users going to lose the access in future.

Is there a way to get this report using PowerShell?

pl suggest.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,097 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,656 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Neuvi Jiang 1,460 Reputation points Microsoft Vendor
    2024-11-15T07:26:17.5466667+00:00

    Hi Prakash Kumar Singh,

    Thank you for posting in the Q&A Forums.

    Below is a general step-by-step guide to help you generate the required reports using PowerShell:

    Getting guest user information using SharePoint Online Management Shell:

    First, make sure you have SharePoint Online Management Shell installed.

    Connect to your SharePoint Online tenant using the Connect-SPOService command.

    Use commands such as Get-SPOSite and Get-SPOUser to get guest user information for a specific site or all sites.

    Track guest access expiration dates:

    The guest user's access expiration date can usually be found in the properties of the user object, but it depends on your SharePoint and Azure AD configuration.

    If the guest expiration policy has been set in Azure AD or SharePoint, you may need to query Azure AD to get this information.

    Use the Microsoft Graph API for more detailed guest information:

    Register an Azure AD application to access the Graph API.

    Use the Graph API to query the guest user and details of their access rights, including expiration dates.

    You may need to write a PowerShell script to automate this process and use the Graph API's authentication token to access the data.

    Generate reports:

    Based on the data you've collected, use a PowerShell script to generate a report listing the guest users who have lost access and those who will lose access in the future.

    You can export the report as a CSV or Excel file for easier analysis and sharing.

    Caution:

    Make sure you have sufficient permissions to access and query the required data.

    Follow relevant privacy and security policies when handling sensitive data.

    Regularly update and test your scripts to ensure they work properly with updates to your Microsoft 365 environment.

    Best regards

    NeuviJ

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  2. Yanli Jiang - MSFT 27,566 Reputation points Microsoft Vendor
    2024-11-15T09:44:20.7033333+00:00

    Hi @Prakash Kumar Singh ,Welcome to Q&A forum!

    Regarding how to get a list of users whose expiration date has exceeded through PowerShell, you can refer to this blog:

    https://o365reports.com/2024/07/16/get-all-expired-anyone-links-in-sharepoint-online-using-powershell/#Download-Script%3A-FindExpiredAnyoneLinks.ps1

    Non-official, just for reference.

    To get a list of users whose expiration dates are about to expire, you can change the date determination in the previous code.

    For your reference:

    https://www.sharepointdiary.com/2021/08/guest-user-access-expiration-in-sharepoint-online-onedrive.html

    https://o365reports.com/2024/07/16/get-all-expired-anyone-links-in-sharepoint-online-using-powershell/#How-to-Identify-Expired-Anonymous-Links-in-SharePoint-Online%3F

    Non-official, just for reference.

    Good day!


    If the answer is helpful, please click "Accept as 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.