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.
- #Variables
- $CSVPath = "D:\Bharat\ODFB\OnedriveUsers1.csv"
- $ListName = "Documents"
- #Get data from CSV
- $CSVData = Import - Csv $CSVPath
- #Iterate through each row in CSV
- ForEach($Row in $CSVData) {
- Try {
- #Connect to SharePoint Online Site
- Write - host "Connecting to Site: "
- $Row.SiteURL
- Connect - PnPOnline - Url $Row.SiteURL - UseWebLogin
- Set - PnPFolderPermission - List $ListName - Identity $Row.Folder - User $UserAccount - AddRole $Row.Role
- DisConnect - PnPOnline
- }
- Catch {
- write - host - f Red "Error Adding User to Group:"
- $_.Exception.Message
- }
- }
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!!