Use PowerShell to automate your Box.com to OneDrive for Business migration.
Index
Prerequisites
Your OneDrives have been provisioned (this can be automated with the Get-OneDriveURL cmdlet).
Note: You need to be site collection admin on each OneDrive, even if you have higher admin privileges. You will use SharePoint admin or global admin permissions to apply site collection admin permissions on all your OneDrives. The PowerShell script will then remove the Site collection admin permissions as you migrate each Box.com account.
How-to
Tip: To migrate your documents to a new folder in your OneDrives, see Walkthrough - Migrate to a new OneDrive folder in PowerShell.
Assign yourself as site collection administrator on all your OneDrives
Open ShareGate Migrate.
Go to All reports.
Click on Create custom report in the top right corner.
Select OneDrive for Business as your object type.
Click Continue without saving.
Select your tenant.
Click on Run.
Select all your OneDrives with the checkmark box at top of the list.
Click Edit in the Quick actions menu.
Select Add administrators in the Transformations dropdown.
Search and add your account in the Select user or group field that appears.
Click Apply.
Create your script
Copy and paste the following script in the PowerShell application of your choice.
Import-Module Sharegate$box = Connect-Box -Email [email protected] -Admin $users = Get-BoxUsers -Box $box$myusername = "myusername"$mypassword = ConvertTo-SecureString 'mypassword' -AsPlainText -Force$tenant = Connect-Site -Url https://mytenant-admin.sharepoint.com -Username $myusername -Password $mypassword foreach ($user in $users) { If ($user.Status -ne 'inactive') { $dstSiteUrl = Get-OneDriveUrl -Tenant $tenant -Email $user.Email $dstSite = Connect-Site -Url $dstSiteUrl -Username $myusername -Password $mypassword $dstList = Get-List -Site $dstSite -name "Documents" Import-BoxDocument -Box $box -DestinationList $dstList -UserEmail $user.Email Remove-SiteCollectionAdministrator -Site $dstSite } }
Adjust your script so that it will work for you. Here are a few guidelines:
$box: Replace the email with your Box.com admin email.
$myusername: Replace "myusername" with your Microsoft 365 account user name.
$mypassword: Replace 'mypassword' with your Microsoft 365 account password.
$tenant: Change the URL to match your tenant's admin center.
foreach: Used to loop through a set of values. In this case, all the commands between the foreach brackets will be repeated for each user in your Box.com account.
Connect-site: The command to connect to a SharePoint site. If you need to change the authentication method, see Connect Site.
Remove-SiteCollectionAdministrator: Removes your user account as site collection administrator on the OneDrive after its migration. For more information, see Remove Site Collection Administrator.
Run your script once it's properly adjusted and tested.
Considerations
To use Browser authentication for your SharePoint site connection (Connect-Site), see Use credentials from a previous browser connection.
You can migrate the content of your user's root folder in Box.com, but not the folder itself. If you want to migrate the Box.com content in a separate folder in OneDrive for Business, you will have to create that destination folder first.
Migration reports are automatically generated, and you will be able to find them in Tasks. You can also export the reports in your script with Export-Report.
You can schedule your migration using PowerShell to run it off-hours and optimize performance.
To perform an incremental migration, see the Incremental update using PowerShell article.
To replicate the copy options from ShareGate Migrate, see Copy options in PowerShell.
Only the files that are owned by the user are migrated. If the user is a collaborator or co-owner of a file, it will not be copied during the migration.
If you experience considerable performance issues, see Box.com throttling.