Forum Discussion

larryleungpowerp's avatar
larryleungpowerp
Copper Contributor
Mar 31, 2025

Obtain Deleted Stats (SharePoint) by Retention Policy

I've scoured: https://learn.microsoft.com/en-us/purview/retention-cmdlets and the Unified Audit Log (https://www.meetingroom365.com/blog/search-unifiedauditlog-powershell/, https://theitbros.com/query-microsoft-365-audit-logs-using-powershell/#penci-Search_the_SharePoint_Online_Audit_Log) to see if I can come up with a method to obtain some statistics regarding how many files and space (storage) has been freed up with the use of retention policies being enabled.

I'm drawing a blank. 

In an ideal world, I'd like know how many files have been deleted by the system (the system enforcing a 5 Year from last modified Date and Delete Policy) for the last year or 6 month intervals.  If possible the corresponding volume of storage space recovered from these deletions.

Any ideas? 

2 Replies

  • How about using the Search-UnifiedAuditLog cmdlet to query audit logs for deletion events? It can help to filter out by date range and action type (e.g., "FileDeleted") to identify files deleted by the retention policy. This might give you a count of deleted files, though it won't directly provide storage statistics.

    • larryleungpowerp's avatar
      larryleungpowerp
      Copper Contributor

      I've begun that path.  Is there a Search query you could suggest?

      Any idea what parameters would be used to filter for only SharePoint sites?

      The search I used previously also seems to include OneDrive deletions.  
      Referenced as "ObjectId":"https://domain-my.sharepoint.com/personal/user_name_domain_com/personal/user_name_domain_com/Lists/PersonalCacheLibrary/WebPartCache/ffcd3017-1840-48bc-a436-d650s14590ea.txt"}

Resources