Search User OneDrives for a Specific Folders Location

Karl Bolland 1 Reputation point
2022-11-28T20:21:49.387+00:00

Hi everyone,

I have been successfully using MS Graph to identify the old 'Shared with Everyone' folders in the root of users OneDrives then delete them or remove the 'Everyone except external users' permission fom the folder.

But I have now discovered that some users have moved the 'Shared with Everyone' folder inside another folder in their OneDrives.

I have tried to use the search and filter queries in Graph API to idenify JUST these folders and their paths, but it brings back too many results that are not just the folder I require.

Can anyone assist in how to do a search either as a global accross all users that contain 'Shared with Everyone' where I can then view the path to see if it is not in the root? Or a way to query a specific users OneDrive for the 'Shared with Everyone' folder as I have the users Drive ID?

Any help would be greatly received.

Thank you!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,743 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Gopinath Chennamadhavuni 2,431 Reputation points
    2022-11-29T11:30:06.627+00:00

    Hi @Karl Bolland ,

    Thanks for reaching out.

    Please refer the below graph API endpoint to fetch the specific folder details from user's OneDrive based on the given name:
    GET https://graph.microsoft.com/v1.0/users/{user-id}/drives/{drive-id}/list/items?$filter=fields/FileLeafRef eq 'Folder-name'&$expand=fields. I have validated it on my test tenant, and I am able to get the details of a specific folder.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.