Office 365 Migration: Migrating User Home Drives to OneDrive for Business


‚ÄčThe Layer2 Cloud Connector for Office 365 and SharePoint can be used to migrate user home drives to OneDrive for Business automatically. A PowerShell script helps to provision the user pages, create the connection files and grant the Cloud Connector Service access to each user page.






When migrating to Office 365, one of the biggest challenges is bringing the individual users’ content from their home drives into the cloud. We've created a process to help you do this with the minimal amount of effort.


Overall, the idea is to create a test connection to work out any configuration necessities, then create the user pages on OneDrive for Business by a script provided, give access to their home drives to a global service account, create connection configurations by script, and let the Layer2 Cloud Connector do the file migration. The Connector helps to:

  • Overcome the 5.000 / 20.000 items limit for sync
  • Automatically solves issues with folder and file names that are restricted in OneDrive
  • Auto-zip forbidden file types
  • Reconnect and continue in case of connectivity issues
  • Synchronize file one-way, as well as two-way after the migration, if required, such as needing to wait until corporate migration is completely finished
  • And more!


The Layer2 Cloud Connector is licensed one-time, per server installation. There are no data-volume related costs - a very important consideration in migration projects. The Migration Tool is a PowerShell script and provided for free, as-is.


Below are the steps for migration using the Migration Tool script and the Cloud Connector.

Part 1: Preliminary Test Connection


Before you start with programmatically creating connections on a mass scale, it is best to start with one connection made by-hand. This will allow you to get familiar with the Cloud Connector product as well as make sure any configuration changes are noted, in case you need to adjust the PowerShell Script used to create the connections that will handle the migration.


Provision a single test OneDrive location to use for this and set up the connection in the Cloud Connector per the detailed walkthrough:
OneDrive File Share Synchronization


Note any adjustments you need to make to the connection, such as authentication method required or special settings. This is so you can change the script output appropriately. By default, the script is going to create a uni-directional connection (File Share to OneDrive) with Office365 as the authentication method.


Once you have a working connection that you can sync manually without errors, you can move to Part 2. If you have trouble with getting your test connection working, contact [email protected] for help.

Part 2: Preparing the Files for Migration


For the best initial synchronization experience with the Layer2 Cloud Connector, we recommend you make sure your file system is clean and free of any of the issues/restrictions known for OneDrive for Business. Restricted file names, characters, and other issues are listed here, and this Office Support article also contains a link to Microsoft's free "Easy Fix" tool near the bottom, meant for fixing your files before you upload them to OneDrive/SharePoint Online.


Note that the 5000 Item view limit and the 20000 total limit listed in the Office Support article does not apply to Cloud Connector, only the OneDrive synchronization tool.

Part 3: Setup for the Migration Tool


You can download the script package here:
Layer2 OneDrive for Business Migration Tool


Before you start, there are some small preparations to do.


The script is written in PowerShell, so you must have the PowerShell console installed on the client machine, as well as have the following Office 365 'cmdlets' installed:



For more information about the Office 365 cmdlets, visit


The client machine needs the following assemblies available:


  • Microsoft.SharePoint.Client
  • Microsoft.SharePoint.Client.Runtime
  • Microsoft.SharePoint.Client.Userprofiles


When you unpack the Migration Tool zip it will contain the PowerShell script itself, two .txt files used for configuration, a folder to collect the created connections, and this users guide.


Below are the description and use of the two configuration .txt files. Both must be filled in with the appropriate data for the script to function properly.




General information about the Office 365 tenant, the administrator account, etc., are stored in a text file named config.txt. This is necessary for both the OneDrive provisioning and the connection file creation.


Example content:

Global Admin Account*[email protected]


Please fill in the settings appropriate for your company.


MSDomain (mandatory)
An Office 365 site URL normally looks like "". Your domain in should be the companyname part of it.
Example: companyname


Global Admin Account (mandatory)
With this account, the script connects to OneDrive for Business and creates the different user sites. It will set itself as contributor on each site to guarantee proper permissions for the Layer2 Cloud Connector to use for access later. For more information about creating/assigning Admin Accounts for O365, see Assign Admin Roles in Office 365.
This account should also be used as service account for the Layer2 Cloud Connector Service.
Example: [email protected]


If you have your own validated domain, and your user account scheme and your OneDrive address does not contain the onmicrosoft pattern, you can define the domain here.
Note: If you have a domain with subdomains (e.g., you have to adjust the PowerShell script for that. We do not support such domains yet.
Example: companyname


If you have your ownvalidated domain, and your user account scheme and OneDrive address is not containing the onmicrosoft pattern, you can define the topleveldomain here.
Example: com





The users.txt file will provide all the necessary user information to the script. Each line in the file is one user (except the very first line, do not edit this). It has the format of:
<base username>;<path to user drive>


The 'base username' is the name without the domain – that was supplied with the config.txt file, so you just need the base name. The 'path to user drive' is standard notation to the specific location in the file share where that user’s content is stored.


For example, if you have a user with the login handle '[email protected]', who has a file share path like 'P:\Userdrives\user1', the file is filled like so:


user1; P:\UserdrivePath\user1
user2; P:\UserdrivePath\user2
user3; P:\UserdrivePath\user3


This notation gives you the chance to provide different user drive paths if you migrate from a heterogenic environment.


Note: The first line of this file is not read as user input. Please leave the comment as is.

Part 4: Running the Script


‚ÄčOnce the script starts, the following steps are performed if you selected the option run the whole script:


1. The config.txt is read.
2. You must type in the password for the Global Administrator Account.
3. The users.txt is read.
4. The script generates the OneDrive and the User Suffixes.
5. A connection to Office 365 is built.
6. The OneDrive for Business instances are provisioned for each user defined in the user.txt file. This will be performed in batches. Please keep in mind that the provisioning will take some time to complete, so this step could last a significant time.
7. For each instance, the script will generate a Layer2 Cloud Connector connection file and save it into the "Connection" folder of this application folder.
8. For each generated OneDrive instance, the Global Administrator Account will be granted access to this instance.


After these steps are completed, your OneDrive environment is set up and ready for data migration.


Note that you can use any part of the script alone, such as just wanting to perform the part that creates the connection files or to go back to a section that had errors to repeat it after you corrected the issue. Just select the numbered action when the script is running to do only that part.


Please note: We provide this script as it is. We cannot guarantee that it will run in your environment without errors. Please only execute if you have appropriate knowledge in these topics and you have sufficient permissions to do so. Layer2 is not responsible for any errors resulted by executing this script.

Part 5: Performing the Migration Synchronization with the Cloud Connector


It's highly recommended that you have completed the file cleanup in Part 2 above before you start this part. While the Cloud Connector can handle many file name issues, it will be a smoother ride with the syncs if those were already taken care of with the "Easy Fix" tool.


Copy the connection files that were created by the script (they should be in the Connection folder that was unpacked with the script) into the Layer2 Cloud Connector working directory. This is usually located at:
C:\ProgramData\Layer2 Cloud Connector\Connections


Open the Cloud Connector application and verify all the connection files load (they will have a red icon if they do not). Now you are ready to start running connections to migrate the data.


It's best-practice to run initial synchronizations manually and alone, if possible. If the amount of data for a user is small, you should be able to run a couple of connections at once, but large data sets should run alone due to the amount of resources they may need. This initial sync can take several hours, up to several days, depending of the amount of data and files to migrate.


Once the initial syncs are complete, you can now enable the scheduling service if you want to keep the OneDrive location in sync with the original file share while you onboard users to their new OneDrive. Please take care to stagger the connections so that not too many run at once for best stability. You can also enable bi-directional syncs which will transfer new content the users add to the OneDrive back to the file share, which may be helpful for longer transitions to the Cloud or having a backup.


If you need assistance with problematic data synchronizations or the Cloud Connector tool, please contact [email protected].



Common Issues and Tips

  • If your company uses ADFS to access Office 365, you need to update the script to create connection files with the proper connection string for ADFS. The change will generally look like this, where you need to define the user as the DOMAIN\Username of the global admin account:
    Authentication=ADFS; OnlineUser='+$AdminUser+'; ; User=DOMAIN\AdminUser; password='+$password+
  • The script creates connection files that have “Overwrite Destination” enabled by default. This means that if the user has any pre-existing content in the OneDrive location, it will be deleted during the sync. Please be aware so you can correct the script, if necessary, and warn your users to avoid file loss during synchronization.
  • The Cloud Connector cannot handle the renaming of paths that are over the limit for OneDrive. This is due to how Windows blocks these files from being accessed, and due to the fact we cannot know how the user will want the folder names truncated. You or the owner of the content will need to rename items in the path until it is under the 260-character limit for OneDrive.
  • Errors like this generally mean that you don’t have all the pre-requisites installed. Check that you’ve installed everything from Part 3 and that your PowerShell version is up- to-date:
    Unable to find type [Microsoft.SharePoint.xxxxxx]. Make sure that the assembly that contains this type is loaded


Layer2 leading solutions product regsitration icon: a grey square with a big orange pen symbol.

Register for free download.

Keep your Sharepoint in sync. Download and try today.

Contact Us Icon for Layer2 leading solutions

Questions? Contact us.

We are here to help. Contact us and our consulting will be happy to answer your questions.