Pre-provision OneDrive for users in your organization
By default, the first time that a user browses to their OneDrive it's automatically created (provisioned) for them. In some cases, such as the following, you might want your users' OneDrive locations to be ready beforehand, or pre-provisioned:
Your organization has a custom process for adding new employees, and you want to create a OneDrive when you add a new employee.
Your organization plans to migrate from SharePoint Server on-premises to Microsoft 365.
Your organization plans to migrate from another online storage service.
This article describes how to pre-provision OneDrive for your users by using PowerShell.
For info about setting the default storage size, see Set the default storage space for OneDrive users.
For info about the storage you get with each plan, see OneDrive Service Description.
Important
The user accounts that you're pre-provisioning must be allowed to sign in and must also have a SharePoint license assigned. To provision OneDrive by using this cmdlet, you must be a SharePoint Administrator and must be assigned a SharePoint license.
Note
If you're pre-provisioning OneDrive for a large number of users, it might take multiple days for the OneDrive locations to be created.
Pre-provision OneDrive for users
If you're pre-provisioning OneDrive for many users, create a list of these users and save it as a file. For example, create a text file named Users.txt that contains:
user1@contoso.com user2@contoso.com user3@contoso.com
Download the latest SharePoint Online Management Shell.
Note
If you installed a previous version of the SharePoint Online Management Shell, go to Add or remove programs and uninstall "SharePoint Online Management Shell."
Connect to SharePoint as a SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.
Note
The PowerShell command Request-SPOPersonalSite works only for users who are allowed to sign in. If you've blocked users from signing in, you can allow them to sign in by running the PowerShell command Update-MgUser using the text file you created in Step 1.
Get-Content -path "C:\Users.txt" | ForEach-Object { Update-MgUser -UserPrincipalName $_ -BlockCredential $False }
Run the PowerShell command Request-SPOPersonalSite, consuming the text file you previously created in Step 1.
$users = Get-Content -path "C:\Users.txt" Request-SPOPersonalSite -UserEmails $users
To verify that OneDrive has been created for your users, see Get a list of all user OneDrive URLs in your organization.
Pre-provision OneDrive for all licensed users in your organization
The following code snippet will pre-provision OneDrive in batches of 199.
$Credential = Get-Credential
Connect-MgGraph -Credential $Credential
Connect-SPOService -Credential $Credential -Url https://contoso-admin.sharepoint.com
$list = @()
#Counters
$i = 0
$j = 0
#Get licensed users
$users = Get-MgUser -All | Where-Object { $_.islicensed -eq $true }
#total licensed users
$count = $users.count
foreach ($u in $users) {
$i++
$j++
Write-Host "$j/$count"
$upn = $u.userprincipalname
$list += $upn
if ($i -eq 199) {
#We reached the limit
Write-Host "Batch limit reached, requesting provision for the current batch"
Request-SPOPersonalSite -UserEmails $list -NoWait
Start-Sleep -Milliseconds 655
$list = @()
$i = 0
}
}
if ($i -gt 0) {
Request-SPOPersonalSite -UserEmails $list -NoWait
}
Write-Host "Completed OneDrive Provisioning for $j users"