One Drive For Business Folder Collaboration To Other ODFB Users

Introduction 

 
Hi guys, let's try to explore a smart process of ODFB specific folders collaboration/permission granting to another ODFB User Account within the same tenant.
 
The permission types possible are:
  • Read
  • Contribute
  • Full Control
Prerequisites
 
- All the Source and Target User Accounts must be ODFB provisioned along with a Microsoft E3-E5 license 
- Windows PowerShell ISE with all PnP packages, modules to be installed 
- Service Account of the Tenant Account to run the PnP script seamlessly
- CSV report with all the columns
 
UserEmail Folder Role SiteURL
[email protected] /personal/veera_kaveri_sample_com/Documents/New Joinees Tasks Read https://sample-my.sharepoint.com/personal/veera_kaveri_sample_com
[email protected] /personal/veera_kaveri_sample_com/Documents/BoxUpdate Contribute https://sample-my.sharepoint.com/personal/veera_kaveri_sample_com
[email protected] /personal/veera_kaveri_sample_com/Documents/Resumes Full Control https://sample-my.sharepoint.com/personal/veera_kaveri_sample_com
 
Process
 
Use the below PnP script after configuring the below-higlighted areas and run it to have the above permission roles assigned to the above folder specific ODFB User Accounts.
  1. #Variables  
  2. $CSVPath = "D:\Bharat\ODFB\OnedriveUsers1.csv"  
  3. $ListName = "Documents"  
  4. #Get data from CSV  
  5. $CSVData = Import - Csv $CSVPath  
  6. #Iterate through each row in CSV  
  7. ForEach($Row in $CSVData) {  
  8.     Try {  
  9.         #Connect to SharePoint Online Site  
  10.         Write - host "Connecting to Site: "  
  11.         $Row.SiteURL  
  12.         Connect - PnPOnline - Url $Row.SiteURL - UseWebLogin  
  13.         Set - PnPFolderPermission - List $ListName - Identity $Row.Folder - User $UserAccount - AddRole $Row.Role  
  14.         DisConnect - PnPOnline  
  15.     }  
  16.     Catch {  
  17.         write - host - f Red "Error Adding User to Group:"  
  18.         $_.Exception.Message  
  19.     }  
  20. }  
Once the above script is run automatically, all the above-mentioned specific folders from their respective ODFB account get permission shared with the Role type mentioned to the User Email mentioned in the CSV rows.
 

Conclusion

 
The entire above process can be used for bulk user accounts permissions/collaborations to various ODFB Folders via PnP scripting by just passing the CSV report prepared in the above format. 
 
Sharing is Caring!!
 
Cheers!!