Preprovision hundreds of OneDrives at the same time

If you want to roll out OneDrive For Business into your organization and you also want to make life easy for the users you can bulk preprovision the OneDrives. Luckily there is a way to retrieve all Office 365 users and with some Excel/Notepad++  tricks you can list them in a txt file and preprovision 200 OneDrives at the same time (you can do this multiple times).

First of all Export the UPN’s from all of the Office 365 users into a CSV file.

Connect the Windows Azure Active Directory module for Windows Powershell (can be downloaded here Azure AD Module for Powershell) to Office 365 with the following cmdlet Connect-MsolService and authenticate with an Office 365 admin account.

Now export the user UPN’s. You can do this with the following cmdlet:  Get-MsolUser | select UserPrincipalName | Export-Csv c:\temp\upn.csv

The first 2 lines can be removed so you are left with only the UPN’s. Next step is to provide this “,” sign in column B for every UPN.


Now we need to make sure the “,” sign is placed behind every user in Column A so we can use it later on in Notepad ++. This can be done with the Concatenate option withing Excel. In column C type in =CONCATENATE and select column A. Then type a , and select column B like in the example below. Then press enter.


Now if everything went ok you will have it like this. If you select the bottom right point in the corner you can drag it all the way down so this will be set correctly for every user.


For the next step we need Notepad++ which can be downloaded for free over here Download Notepad++ After starting up under view enable Word Wrap. Then copy paste your Column C from Excel into Notepad ++ so it looks like this.


With the next nifty little trick we can modify the data output so we can use it to preprovision the OneDrives in our script. Place your cursor after the first user and drag it to the second one. End your selection before the first user in line 2 so in fact nothing is selected except a space on the end of line 1 (see example).


Now press Ctrl+H to start the Find & Replace function. Then just press “Replace All” and select “Close”


Now everything is set correctly and should look similar to this.


The only thing left to do is connect the Sharepoint Online Management Shell (can be downloaded here Sharepoint Online Management Shell) and preprovision the OneDrives.

Login with the following cmdlet (Where TENANT is the name of your Office 365 tenant) Connect-SPOService -Url -credential

Preprovision the Onedrives with the following cmdlet. Note that in front of the first UPN and after the last UPN is a ” sign and you can only run 200 UPN’s at the same time. I recommened waiting a couple of minutes before providing the next 200 UPN’s 🙂

$emails = “”,””,””,””,””,””
Request-SPOPersonalSite -UserEmails $emails -nowait

9 Replies to “Preprovision hundreds of OneDrives at the same time”

  1. I am getting an error saying:
    Request-SPOPersonalSite : Access denied. You do not have permission to perform this action or access this resource.

    Any ideas? I am using an admin account.

  2. I am struggling with an issue with some users not being preprovisioned with their OneDrive. So this post is very useful for me right now. Thanks for posting about this

  3. If you’ve got a list of users you want to add in a text file, each on a separate line, the following powershell will work for you:

    $UPNs = “”
    Get-Content -path [path to your input file] | foreach { $UPNs += “””” + $_ + “””,”}
    Request-SPOPersonalSite -UserEmails $UPNs

    1. ** Correction to my post yesterday **

      If you’ve got a list of users you want to add in a text file, each on a separate line, the following powershell will work for you:

      [string[]]$UPNs = Get-Content -path [path to your input file e.g. .\ODfBUserList.txt]
      Request-SPOPersonalSite -UserEmails $UPNs

      (Amended as the command requires an array of strings and not a string of comma-separated strings! #shouldhavetestedproperly)

      If this is working correctly, you will see a pause of about 1 second per user (unless you use the -nowait switch). The sites may not appear for up to 24 hours, but for small batches they typically seem to be quick – sometimes only a few seconds.

Leave a Reply

Your email address will not be published. Required fields are marked *