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 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 = “email@example.com”,”firstname.lastname@example.org”,”email@example.com”,”firstname.lastname@example.org”,”email@example.com”,”firstname.lastname@example.org”
Request-SPOPersonalSite -UserEmails $emails -nowait