How to generate a historical OneDrive folder sharing and access report for the past 2–3 years?

Koshila Dodantenna 0 Reputation points
2026-11-05T22:56:11.4933333+00:00

Hi everyone,

We have a client who uses a dedicated Microsoft 365 account with an E3 license as a central file storage system, basically using OneDrive as an alternative to a traditional file server.

The main OneDrive account holds multiple folders, which are shared with different staff members depending on their job roles. Over time, some of these staff members have also shared subfolders with other internal users and external parties.

The client has now requested an audit report for one specific main folder, which contains several levels of subfolders.

They want to find out:

  • Who shared each folder or subfolder, and with whom (both internal and external users).

When those folders were shared.

Who actually accessed the folders or files, including any external users.

Whether those users still have access.

Ideally, they would like this information going back 2–3 years.

We have Microsoft 365 admin access and I've started looking into Microsoft Purview Audit, but from what I understand, the standard audit log retention for E3 is only 180 days.

My questions are:

Is there any way to retrieve historical sharing and access activity going back 2–3 years, or is that data permanently unavailable once the audit retention period expires?

Is there a way to generate a report covering a specific OneDrive folder and all its subfolders, rather than auditing the entire OneDrive?

Can Microsoft Graph or PowerShell be used to identify who originally shared each folder, who it was shared with, and who currently has access?

Are there any Microsoft-native tools or alternative approaches that would help generate this type of report?

We're mainly looking for a practical way to produce a comprehensive report without having to manually inspect hundreds of folders and their individual sharing permissions.

Any guidance or recommendations would be appreciated.

Thanks!

Microsoft 365 and Office | OneDrive | For business | Windows
0 comments No comments

2 answers

Sort by: Newest
  1. Dora-T 2,075 Reputation points Independent Advisor
    2026-11-06T00:45:29.73+00:00

    Hi @Koshila Dodantenna

    Based on my research, here are my findings regarding each of your questions:

    1.Is it possible to retrieve OneDrive sharing and access activity from 2–3 years ago? 

    Unfortunately, it depends on whether the audit data was retained at the time the activities occurred. 

    According to Microsoft documentation, Microsoft Purview Audit (Standard) retains audit records for a limited period (currently up to 180 days for supported workloads). Once audit records expire, they cannot be recovered retrospectively unless they were previously exported or collected by another system (for example, Microsoft Sentinel, a SIEM solution, or a third-party archive). 

    Upgrading the license or creating a retention policy now will not restore expired records, as retention policies only apply to new audit data. Extended audit retention requires the appropriate Microsoft Purview Audit (Premium) licensing and must be configured before the audit records expire.

    If no previously exported audit files, SIEM, or backup data exists for this tenant, the 2–3 year history is not recoverable. 

    Reference: 

    Learn about auditing solutions in Microsoft Purview | Microsoft Learn 

    Manage audit log retention policies | Microsoft Learn 

    2.Is there a way to generate a report for a specific OneDrive folder and all of its subfolders? 

    There is no built-in Microsoft 365 report that automatically reconstructs the historical sharing and access history of a particular folder hierarchy. 

    For audit data that is still within the available retention period, you can search Microsoft Purview Audit logs and then filter the results based on the folder path (for example, using the ObjectId value in the exported audit records) to identify activities related to a specific folder and its descendants. Relevant sharing and access operations may include SharingSet, SharingInvitationCreated, AnonymousLinkCreated, SecureLinkCreated, AddedToSecureLink, SharingRevoked, and FileAccessed, where available.

    Reference: Search the audit log | Microsoft Learn 

    3.Can Microsoft Graph or PowerShell identify who originally shared folders, who they were shared with, and who currently has access? 

    This depends on whether you are looking for historical or current information. 

    For current access, Microsoft Graph and PowerShell can list the folders and their permissions, including users, groups, guests, sharing links, permission levels, and whether each permission is inherited or directly assigned. Permissions are retrieved per item (Get-MgDriveItemPermission), so you will need to loop through the folder tree. 

    For historical sharing details (for example, who originally shared a folder and when), this information comes from audit records. If those logs have already expired, Graph cannot reconstruct the events. A current permissions snapshot also cannot reliably show who shared an item originally, when it was shared, or who had access in the past. 

    References: 

    List who has access to a file - Microsoft Graph v1.0 | Microsoft Learn 

    Get-MgDriveItemChild (Microsoft.Graph.Files) | Microsoft Learn 

    4.Are there any Microsoft-native tools or alternative approaches available? 

    Microsoft provides several options for reporting on current permissions and available audit data:

    -OneDrive Sharing Report (Run sharing report) to export current sharing relationships, users, permissions, and sharing links. 

    Reference: Report on file and folder sharing in a SharePoint site - SharePoint in Microsoft 365 | Microsoft Learn 

    -Microsoft Graph / PowerShell to build a custom current-permissions inventory for a specific folder tree. 

    -Microsoft Purview Audit to review available sharing and access activities within the retained audit period. 

    -SharePoint Advanced Management / Data Access Governance reports for broader visibility into sharing and permissions across the organization. These reports reflect the current state only and may require additional licensing.

    References: Data access governance reports - get site permission states snapshot report for SharePoint sites - SharePoint in Microsoft 365 | Microsoft Learn 

    For more information, you may also refer to the AI Answer below, which includes example PowerShell approaches for searching available audit records and retrieving current permission information.

    Best regards,  

    Was this answer helpful?


  2. AI answer

    2026-11-05T22:57:18.9033333+00:00

    With an E3-licensed account, activity older than the applicable Purview Audit retention period cannot be recovered retrospectively unless it was previously exported or collected by another system; produce the report by combining the retained audit events with a separate snapshot of current permissions.

    1. Historical sharing and access

    Audit (Standard) retains records for 180 days. Records generated before October 17, 2023 had a 90-day default retention period. Changing the license or creating a retention policy now does not restore expired records—the retention lifetime is determined when the audit pipeline receives each record.^1^

    Therefore, a complete 2–3-year report is possible only if older records already exist in one of these places:

    • A SIEM or archive populated through the Office 365 Management Activity API.
    • Previously exported Purview CSV files.
    • Another monitoring or backup product that collected the events while they remained available.

    Audit Premium provides one-year default retention for OneDrive and SharePoint activity for appropriately licensed users. Retention policies can extend this to 10 years with the required add-on, but policies are prospective, not retroactive.^2^

    2. Search the retained period for the folder tree

    In Microsoft Purview portal → Audit → Search:

    1. Select a date range within the available retention period. A single portal search can span no more than 180 days.
    2. Use the main folder’s path or URL in Keyword Search.
    3. Select the relevant sharing and access operations.
    4. Export the completed results to CSV.
    5. In Excel/Power Query, expand the AuditData JSON and retain records whose ObjectId starts with the main folder’s URL/path.

    Keyword Search only searches indexed fields in the common audit schema, not every property inside AuditData. Consequently, filtering the exported ObjectId values by the folder-path prefix is the more reliable way to include descendants.^3^

    Relevant sharing operations include:

    • SharingSet — shared with an internal directory user or guest.
    • SharingRevoked
    • SecureLinkCreated
    • AddedToSecureLink — identifies the person added to a specific-people link.
    • AnonymousLinkCreated and AnonymousLinkUsed
    • SharingInvitationCreated and SharingInvitationAccepted
    • FileAccessed for authenticated access through secure links.

    For external sharing, fields such as TargetUserOrGroupName, TargetUserOrGroupType, and ObjectId help identify the recipient, guest status, and affected resource.^4^ The complete operation definitions are listed in the audit activity reference.^5^

    For repeatable extraction, Search-UnifiedAuditLog supports filtering by operations, users, target objects, and date range. Use the same folder-path prefix against the returned JSON:

    $operations = @(
      "SharingSet","SharingRevoked","SecureLinkCreated",
      "AddedToSecureLink","AnonymousLinkCreated",
      "AnonymousLinkUsed","FileAccessed"
    )
    
    $events = Search-UnifiedAuditLog -StartDate $start -EndDate $end `
      -Operations $operations -SessionId "OneDriveFolderAudit" `
      -SessionCommand ReturnLargeSet -ResultSize 5000
    
    $events | ForEach-Object { $_.AuditData | ConvertFrom-Json } |
      Where-Object ObjectId -like "$folderUrl*" |
      Export-Csv .\FolderAudit.csv -NoTypeInformation
    

    Repeated calls with the same session are required until no further records are returned. ReturnLargeSet supports exhaustive searches up to 50,000 results; Microsoft recommends the Management Activity API for larger programmatic collection.^6^

    3. Inventory who still has access

    Microsoft Graph can enumerate the folder tree and retrieve each item’s current effective permissions, but it does not replace expired audit history. For each folder:

    Import-Module Microsoft.Graph.Files
    
    $children = Get-MgDriveItemChild `
      -DriveId $driveId -DriveItemId $folderItemId -All
    
    $permissions = Get-MgDriveItemPermission `
      -DriveId $driveId -DriveItemId $folderItemId
    
    $permissions | Select-Object Id, Roles, GrantedToV2,
      GrantedToIdentitiesV2, Link, InheritedFrom
    

    Recursively call Get-MgDriveItemChild for every item having a folder facet.^7^

    The permissions endpoint reports direct and inherited effective permissions, sharing links, recipients, and roles. It must be called separately for each item; permissions cannot be expanded while listing a folder’s children.^8^ For application access, the documented least-privileged permission is Files.Read.All; an item owner receives all sharing permissions, while a non-owner may receive only permissions applicable to that caller.

    This snapshot answers who currently has access and how, but it cannot reliably reconstruct an expired sharing event’s original actor, date, subsequently revoked recipient, or historical access. Those answers require retained audit events.

    4. Microsoft-native current-state reports

    As a site administrator, run OneDrive → Settings → OneDrive settings → More settings → Run sharing report. It creates a CSV of every unique file, user, permission, and sharing link in that OneDrive.^9^ Filter its item paths to the requested main folder. This is a current-state report, not a 2–3-year activity report.

    SharePoint Advanced Management also provides organization-wide OneDrive permission snapshots, including guest permissions, sharing links, and items with broken inheritance. It is useful for exposure assessment but likewise does not reconstruct historical sharing or access.^10^

    For future investigations, configure extended Purview retention or continuously export the Management Activity API feed to durable storage/SIEM.


    References

    1. Learn about auditing solutions in Microsoft Purview
    2. Manage audit log retention policies
    3. Search the audit log
    4. Use sharing auditing in the audit log
    5. Audit log activities
    6. Search-UnifiedAuditLog-Syntax
    7. Get-MgDriveItemChild-Syntax
    8. List sharing permissions on a driveItem
    9. Report on file and folder sharing in a SharePoint site
    10. Get your organization's site permissions baseline with the snapshot report
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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