Use PowerShell batch enable OneDrive for business

Source: Internet
Author: User

To update a blog, this is a simple way to talk about how to bulk enable OneDrive for work for Office 365 users, some people may have a face, this thing still need to enable? Isn't it self-brought? In fact, Office 365 users can enjoy the storage space provided by OneDrive for business as long as they have purchased the qualifying license. But, this storage space is not opened the account will be automatically generated! This storage space is generated by the user click on the OneDrive icon to start, the first time you click on OneDrive may find it will take a while to enter the page, in fact, the background is doing this.

Some people may be more confused how does this affect me? No matter when he was generated, I just want to make sure I can use it properly. Yes, this is true for the user, but it has a big impact on IT administrators!

For example, if I want to do SharePoint to SharePoint Online, or migrate from a file share to SharePoint Online, in this case, if the user's OneDrive for When business is not generated at the time of migration, there are some problems with the error, because the goal of the migration is actually nonexistent.

In order to solve this problem, in fact, the administrator can be scripted in advance for users to generate OneDrive for storage space, which is a key prerequisite for batch migration!

How to do this, look at the share below, first you can see clearly on the portal that the user's OneDrive is not automatically generated

1. First 1th, install the PowerShell SharePoint Online Module

2. After the installation is complete, you can open PowerShell to verify that the installation was successful

The SharePoint Online module has a longer name, can be import and then get to the command in module

Get-command-module Microsoft.Online.SharePoint.PowerShell

3. In addition to installing the SharePoint Online Client components SDK, there are some assembly that cannot be successfully load

4. Once the preparation is complete, we can enable OneDrive through the script.

First look at how to run the script, the main thing is actually two parameters, Spoadminurl, this is actually your O365 shareonline Management Center URL, there is a inputfilepath, this is actually a file, It's going to record the UPN that needs the Enable user.

5. Once you have logged in to the portal, you can see that OneDrive has been successfully

Finally share the source code of the script

<#. example.\bulkenqueueonedrivesite.ps1 -spoadminurl - inputfilepath c:\users.txt . parameter spoadminurl the url for the sharepoint admincenter https:// inputfilepath the path to the input  File. the file must contain 1 to 200users c:\users.txt.notes this  script needs to be run by aSharePoint Online Tenant  Administrator this script will prompt for the usernameand password  of the tenant administrator#>param (     #Must  be  Sharepoint administratorurl    [parameter (mandatory = $true)]     [validatenotnullorempty ()]    [string]  $SPOAdminUrl,    &nbsP;    [parameter (mandatory = $true)]    [validatenotnullorempty ()]     [string] $InputFilePath) [System.reflection.assembly]::loadwithpartialname (" Microsoft.SharePoint.Client ") | out-null[system.reflection.assembly]::loadwithpartialname (" Microsoft.SharePoint.Client.Runtime ") | Out-null[system.reflection.assembly]::loadwithpartialname ("Microsoft.SharePoint.Client.UserProfiles") |  Out-null$ctx = new-object microsoft.sharepoint.client.clientcontext ($SPOADMINURL) $Users  =  Get-Content -Path  $InputFilePathif   ($Users. count -eq 0 -or $ users.count -gt 200) {    write-host $ ("unexpected usercount: [{0} ] " -f  $Users. Count)  -foregroundcolor red    return } $web  =   $ctx. webwrite-host  "Please enter a tenant admin username"  -ForegroundColorGreen$ username = read-hostwrite-host  "Please enter your password"  - Foregroundcolorgreen$password = read-host -assecurestring$ctx. Credentials = new-objectmicrosoft.sharepoint.client.sharepointonlinecredentials ($username, $password) $ctx. Load ($web) $ctx. ExecuteQuery () $loader  =[microsoft.sharepoint.client.userprofiles.profileloader]::getprofileloader ($CTX) $ CTx. ExecuteQuery () $loader. Createpersonalsiteenqueuebulk ($Users) $loader. Context.executequery () write-host  "script completed"

Also share the components you need to use.

SharePoint Online Client Components SDK

SharePoint Online Module

Use PowerShell batch enable OneDrive for business

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.