File share to OneDrive for Business File Migration?

Iron Contributor



Interesting one, I'm looking to migrate file share data (home drives) to OneDrive for Business using PowerShell.  I've hit a bit of an issue with permissions on "my sites".  For information I've created a new user for doing the data migration, this is a cloud only user that has Global access on the tenant.

The PowerShell scripts run under this credential however the issue is it doesn't have access to the users my site, in a on-prem scenario I would add the admin account to the web application and life would be rosey.  I thought that I could add the admin account to the site within the SPO admin console but this doesn't seem to have any affect on sites already created.  If I add the data migration user to the users mysite as a site collection admin the import process runs perfectly.


So any thoughts how i can get around this issue without having to interact with the users?  Powershell to add the data migration user to the user my sites?

2 Replies
best response confirmed by Rob Clarke (Iron Contributor)

Just include the following before/after migrating:



Set-SPOUser -Site $onedrive -IsSiteCollectionAdmin $true -LoginName
# ...migration...
Set-SPOUser -Site $onedrive -IsSiteCollectionAdmin $false -LoginName


where $onedrive contains the URL of the user's Onedrive actually being migrated, like:



This grants site collection admin rights to the given users Onedrive for the technical user whose credentials are used for the migration, then remove it once you are done.

@Zoltan Bagyon Genius! thanks for that.