top of page

SharePoint Online shared files report

  • romanvitsinskyi
  • Oct 28
  • 1 min read
SharePoint Online

Ever had a need to generate report of files shared in SharePoint Online and / or OneDrive for Business? Purview makes it easy, but report might take a while to run and downloadable report will need to be parsed in Excel, which might get time consuming with bunch of unnecessary clicks. Use below PowerShell script to easily query all sharing operations with nicely formatted output. Report is saved as @SPO_Sharing variable, just export to csv.

Hope you'll find it useful! Cheers



$SPO_sharing = @()

Search-UnifiedAuditLog -StartDate mm/dd/yyyy -EndDate mm/dd/yyyy -Operations SharingSet,SecureLinkCreated,SharingInvitationCreated,AnonymousLinkCreated,AddedToSecureLink,SharingInvitationAccepted,AnonymousLinkUsed,AccessRequestCreated,CompanyLinkCreated,AccessRequestUpdated -ResultSize 5000 | % {
$log = $_
$details = $_.AuditData | ConvertFrom-Json

$SPO_sharing += $log | Select CreationDate,UserIds,RecordType,Operations,` @{N="TargetUserOrGroupType"; E={$details.TargetUserOrGroupType}}, `
@{N="TargetUserOrGroupName"; E={$details.TargetUserOrGroupName}}, `
@{N="AuthenticationType"; E={$details.AuthenticationType}}, `
@{N="IsManagedDevice"; E={$details.IsManagedDevice}}, `
@{N="ObjectId"; E={$details.ObjectId}}, `
@{N="ItemType"; E={$details.ItemType}}, `
@{N="Permission"; E={$details.Permission}}, `
@{N="SharingLinkScope"; E={$details.SharingLinkScope}}, `
@{N="ClientIP"; E={$details.ClientIP}}, `
@{N="Workload"; E={$details.Workload}}, `
@{N="UserAgent"; E={$details.UserAgent}}
}

Reference:


 
 
bottom of page