Introduction
Let's learn a smart way of adding a given user account as a Secondary Admin to a given ODFB User Account's site collection.
Every ODFB User account is also a kind of Site Collection.
Manual Process is goto the respective One Drive For Business login site >> Goto Top right corner Cog >> OneDrive Settings >> More Settings >>Site Collection Administrators >> Add the new user account that needs to be added as a Secondary Admin >> Click Ok.
The new User Account can also access the given ODFB URL along with all the content that includes Folders, Sub Folders, Files, etc.
Prerequisites
- All the Source and Target User Accounts must be ODFB provisioned, along with a minimum 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
- All the new accounts to be added as a Secondary Admin need to be created within the same Microsoft Tenant
- All existing ODFB accounts also are to be used from the same Microsoft Tenant.
Programmatical Approach
- #Set Runtime Parameters
- $AdminSiteURL="https://xxxapc-my.sharepoint.com"
- $SiteUrl="https://xxxapc-my.sharepoint.com/personal/rajesh_raju_xxx_com"
- $SiteCollAdmin="[email protected]"
- Connect-PnPOnline -Url $SiteUrl -UseWebLogin
- #Connect-PnPOnline -Url $SiteUrl -CurrentCredentials
- Add-PnPSiteCollectionAdmin -Owners $SiteCollAdmin
Note
If you are using a User Account for the Connect-PnP Online, which is itself a non-Secondary Admin Account on the above ODFB Site URL, you can't have the output achieved and shall get the above yellow border highlighted as an error initially.
Only if you use a proper User Account for the Connect-PnP Online, which is itself a Secondary Admin Account on the above ODFB Site URL, you can have the output achieved and get the above yellow border highlighted as an error.
Conclusion
Finally, we are able to add the above user account as a Secondary Admin to the specified ODFB Siteurl using a simple PnP Script by running on the Windows PowerShell ISE.
The above concept can furthermore be used to add multiple user accounts as a Secondary Admin by passing it in the form of a CSV file.