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.

scr1

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.

scr6

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.

scr7

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.

scr8

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).

scr9

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

scr4

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

scr10

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 https://TENANT-admin.sharepoint.com -credential admin@TENANT.onmicrosoft.com

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 = “test8@blogoffice.onmicrosoft.com”,”test7@blogoffice.onmicrosoft.com”,”test6@blogoffice.onmicrosoft.com”,”test9@blogoffice.onmicrosoft.com”,”test10@blogoffice.onmicrosoft.com”,”admin@blogoffice.onmicrosoft.com”
Request-SPOPersonalSite -UserEmails $emails -nowait

Share this blog!

7 thoughts on “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

Leave a Reply

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