List Shared files + File Size in ODB

Steel Contributor

i haven't found any API or Powershell cmdlet to get for each user a list of


- shared files

- with the corresponding file size


(also the lastest news around Graph API does not help here :(


i would like to use this  information to get a better understanding if users are mainly using onedrive for private purpose or if they share files whenever they upload them to onedrive.


Having metadata information such as (filesize, file type, to whom the file is shared, etc..) would further help to understand the user behavior



2 Replies

A "Shared by me" virtual folder (or something similar) has been promised, but without ETA.

Maybe it could come with some PowerShell cmdlet. We will see...

 Pls check below script to get Sharing details of single user ODFB . and You need use PnP Sharepoint Online  Powershell module. 


$cred = Get-Credential
Connect-PnPOnline -Url "" -Credentials $cred
$Ctx= Get-PnPContext
$lists= Get-PnPListItem -List "documents"
$Files = @()
foreach( $list in $lists)
    $FDetails = "" | Select "FilePath","SharedWith","FileSizeInMB"
    #Check weather is file or not
    If($list.FileSystemObjectType -ne "Folder")
        $roles= $list.RoleAssignments
        #check file is shared 
        If($roles.Count -gt 0)
          #Join Shared UserName 
          $rec = ''
          for ($i = $roles.Count -1; $i -ge 0 ; --$i)  
                          $rec=$rec + ";" + $m.Title

            #Add File Informations
            $FDetails.SharedWith =$rec
            $FDetails.FileSizeInMB= $list.FieldValues["File_x0020_Size"]/1mb
            $Files +=$FDetails
            $FDetails =$null

  $Files |fl


If you want to check each users ODFB sharing details, you need to add secondary site collection admin for each OFDB users, You can refer below link for add secondary admin to ODFB users