How do I get a list of all O4B files shared with others - for all users

Brass Contributor

I need to get a list of all files all users shared with others sorted by user and then by file URL. The tenant has more than 400 users.


Audit log search does not work because it does not show shared files where sharing started before audit log start date and it does not show file name and path. I also found this script: But it seems to work for one particular user only. 


Can anybody help?

7 Replies
Can't use that function in that script and pipe to it from the get command that gets all your onedrive sites?
You can get all the ODFBs through PowerShell and then use the script you have found. For instance, the following support article provides a PowerShell script to get all the ODFBs in an Office 365 subscription:

Um, why don't you simply use eDiscovery/content search and the SharedWithUsersOWSUser (internal) or the ViewableByExternalUsers (external) keyword? More info here:

That was my first thought but I couldn't figure out how you would call that. Good info for future thou. Thanks :).
Not sure it gives URL etc. to the file thou.

It does, and it can give you the actual item as well, if you want to export it :)

@VasilMichev Why I didn't saw thosw two conditions in my search conditions.


How could I search document which is share with second option


Screenshot 2020-12-03 145205.png