OneDrive Access

Glenn Maxwell 10,146 Reputation points
2022-05-19T20:58:38.587+00:00

Hi All

One of my user lets say user1 has the left the company and his user account is in disabled state. i have a requirement to provide access for few folders of user1's onedrive to user2.
Lets say below are the folders in user1's onedrive. how do i provide access to these folders to user2 from powershell.

Test1 A
Test2 B

If i use the below syntax i can provide access to complete OneDrive but i am not sure how to provide access to few folders. experts guide me. in the below i am taking contoso as an example.

Set-SPOUser -Site https://contoso-my.sharepoint.com/personal/user1_contoso_com -LoginName user2@contoso.com -IsSiteCollectionAdmin $true
SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,216 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,606 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,118 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yi Lu_MSFT 17,456 Reputation points
    2022-05-20T07:25:33.243+00:00

    Hi @Glenn Maxwell
    You could tyr "Set-PnPFolderPermission" to grant permission for user in folder, for example:

    Set-PnPFolderPermission -List 'Shared Documents' -Identity 'Shared Documents\Folder' -User 'user@contoso.com' -AddRole 'Contribute'  
    

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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Vasil Michev 95,096 Reputation points MVP
    2022-05-20T07:15:43.99+00:00

    You cannot use PowerShell to provide access to specific folders/files only. The cmdlet above will give access to the entire content of the user's OneDrive. If that's not what you want, grant permissions to your admin user, open the OneDrive and then use the Share functionality against the folders in questions. If you want to achieve this programmatically, use CSOM or the Graph API.

    0 comments No comments

  2. sadomovalex 3,626 Reputation points
    2022-05-20T14:33:17.937+00:00

    check the following solution suggested by Microsoft: Give another employee access to OneDrive and Outlook data.

    0 comments No comments