In this blog, we will migrate on-prem home drives located on a file server into Microsoft OneDrive for Business.  The Home drives are all on a file share in one location.  We will run a PowerShell script to extract the folder names which will also be used to map the OneDrive user accounts.  To do the final migration we will leverage the ShareGate tool.  More and more companies are leveraging the cloud for home drives as it can be accessed from any device and eliminate the need for a VPN or Direct Access.  Many companies also already have access to OneDrive for Business with their Office 365 license and can take advantage of this to retire file servers and free up space.



The Prerequisites you will need to get started are:


Get a list of all folders in your home drive directory. 

Note: we are assuming the folders follow in line with username.  More data manipulation may be needed in your case.

dir -Directory \\server\folder -Name | Out-File "C:\Temp\folderlist.csv"




                You should now have your list in C:\Temp\folderlist.csv




(if Needed) OneDrive accounts must be provisioned before the migration can take place.

  • An Email accounts list can be created from the previous step.
    • Open folderlist.csv and add the function to column B
      • =A1&””



  • You can drag the bottom right corner of the box around This email address is being protected from spambots. You need JavaScript enabled to view it. down to as many rows as you must populate the rest of the email addresses and save as users.txt.
  • Follow the steps here to provision the accounts you will need the PowerShell script for the nex step:
  • Run Command to Provision the OneDrive Accounts: (SharePoint Online Management Shell)

.\BulkEnqueueOneDriveSite.ps1 -SPOAdminUrl -InputfilePath C:\Temp\users.txt



Add Headers to the original folderlist.csv

  • Add headers to column A for DIRECTORY and column B for ONEDRIVEURL




On Column B add formula to concatenate file path to the beginning of the directory listing:


Drag the bottom right of row 2 column be down to the end of your list to populate all.




On Column C add formula to concatenate ONEDRIVEURL




Copy Paste lines to another csv to get look like this: (may need to go to/from notepad to get rid of the formula and get the new text.)



Final CSV Format:




ShareGate Migration:

Your account must have rights to all OneDrive Accounts, can do this using ShareGate:


Contents of Migrate_W_ShareGate.ps1:


#Example CSV file with columns titled DIRECTORY and ONEDRIVEURL:

$csvFile = ".\folderlist.csv"

#load the CSV file into a table

$table = Import-Csv $csvFile -Delimiter ";"

#Convert your password to a SecureString

$mypassword = ConvertTo-SecureString YOURPWD -AsPlainText -Force

#Cycle through each row

foreach ($row in $table)


#connect to the destination OneDrive URL

$dstSite = Connect-Site -Url $row.ONEDRIVEURL -UserName This email address is being protected from spambots. You need JavaScript enabled to view it. -Password $mypassword

#select destination document library, named Documents by default in OneDrive

$dstList = Get-List -Name Documents -Site $dstSite

#Copy the content from your source directory to the Documents document library in OneDrive

Import-Document -SourceFolder $row.DIRECTORY -DestinationList $dstList -InsaneMode





#NOTE: update YOURPWD and This email address is being protected from spambots. You need JavaScript enabled to view it. in the PowerShell Script.


Run Powershell Script to migrate using Sharegate:





Each Input file is limited to 200 users. If you need to provision OneDrive for Business sites for more than 200 users, create multiple input files (for example, UserInput1.txt, UserInput2.txt, etc.).