Using PowerShell, you can move a traditional network file share to OneDrive for business.
- Full control on your DOMAIN folder.
- The DOMAIN folder is mapped as a network drive.
- Your OneDrives have been provisioned.
- This can be automated with the Get-OneDriveURL cmdlet.
- The account you are using is set as an administrator for each individual OneDrive.
- This can be done using the Add-SiteCollectionAdministrator cmdlet.
- Generate a list of the names of all the directories contained in the DOMAIN folder using this script (replace the folder path with your path):
dir –Directory Z:\ -Name | Out-File C:\MigrationPlanning\onedrivemigration.csv
- You will now have a CSV file with a list of all directories contained in the DOMAIN mapped drive.
- Create a header column by inserting a column at the top of the CSV file.
- Name it DIRECTORY.
- Insert the correct mapped drive letter before the names of the directories in your columns (i.e. Z:\).
- Using Reporting, run a new report, select OneDrive for Business as your object type, and select to export report .
- You will have a row of your OneDrive URLS. Insert a header column, and name this row ONEDRIVEURL.
- You now have two excel sheets, one with DIRECTORY and one with ONEDRIVEURL.
- Combine the two sheets manually (copy/paste), or using PowerShell, so that each directory corresponds the the correct URL.
- Generate a table based off of your CSV file using this script (replace the folder path with your path):
$csvFile = "C:\MigrationPlanning\onedrivemigration.csv" $table = Import-Csv $csvFile -Delimiter ";"
- Use this script to allow PowerShell to use the table to run your migration (replace the folder path with your path):
################# #Example CSV file with columns titled DIRECTORY and ONEDRIVEURL: $csvFile = "C:\MigrationPlanning\onedrivemigration.csv" #load the CSV file into a table $table = Import-Csv $csvFile -Delimiter ";" #Convert your password to a SecureString $mypassword = ConvertTo-SecureString "mypassword" -AsPlainText -Force
#Initialize your variables
Set-Variable dstSite, dstList
#Cycle through each row foreach ($row in $table)
#clear your variables to avoid any misdirection issues if one connection fails in the process
#connect to the destination OneDrive URL $dstSite = Connect-Site -Url $row.ONEDRIVEURL -UserName email@example.com -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 $result = Import-Document -SourceFolder $row.DIRECTORY -DestinationList $dstList -InsaneMode #Export a report for each OneDrive migration with the session ID as the title in a designated destination #Any folder specified in the path has to exist before running the script Export-Report $result -Path C:\MyReports\ } #################
- Use the Export-Report cmdlet to review your migration report.
Note: You can schedule your migration using PowerShell to run it off-hours and optimize performance.