My issue is similar to another posted here on the site but still happening(Office 365 pre-provision my site issue with Powershell). I've tried to run this on 3 different machines and 1 works, the other two don't.

The following assemblies are installed and loaded on all 3 machines with the same version:

SharePoint Client Components: 16.0.4002.1211
MS Online Services Sign-In Assistant: 7.250.4556.0
Azure AD Module for Windows: 1.0.0 **(I don't think this one is needed)**

On one machine (my laptop), I get an error on the line:

$loader =[Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($ctx)


Cannot convert argument "context", with value: "Microsoft.SharePoint.Client.ClientContext", for "GetProfileLoader" to type "Microsoft.SharePoint.Client.ClientRuntimeContext": "Cannot convert the "Microsoft.SharePoint.Client.ClientContext" value of type "Microsoft.SharePoint.Client.ClientContext" to type "Microsoft.SharePoint.Client.ClientRuntimeContext"."

On the other machine (2013 SP WFE), the error is on line:



One Drive Not Provisioned Method invocation failed because [Microsoft.SharePoint.Client.UserProfiles.ProfileLoader] does not contain a method named 'CreatePersonalSiteEnqueueBulk'.

I know I'm missing an assembly, reference, version or something but I can't figure out what it is.

$Domain = "@mydomain.com"

Write-Host "Load SharePoint and One Drive Assemblies" -ForegroundColor Yellow
$loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
$loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
#Must be SharePoint Administrator URL
$webUrl = "https://SiteDomain-admin.sharepoint.com"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)

Write-Host "Create Connection To Administration Site" -ForegroundColor Yellow   
$web = $ctx.Web
$username = "me@myDomain.com"
$password = ConvertTo-SecureString '*************' -AsPlainText -Force

$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$password )

Write-Host "Load website into cache" -ForegroundColor Yellow

$loader =[Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($ctx)

#To get the profile
$profile = $loader.GetUserProfile()

Write-Host "Loading User Array" -ForegroundColor Yellow
$UserArray = "User1", "User2", "User3","User4"
Foreach ($user in $UserArray)
        #To queue up the profile
        Write-Host "$user One Drive Provisioned" -ForegroundColor Cyan
        Write-Host "$user One Drive Not Provisioned" $_.Exception.Message -ForegroundColor Red
Write-Host "COMPLETED"  -ForegroundColor Green

You don't need to do all that work anymore. In a recent update to the SharePoint Online Management Shell, there is a commandlet to do this for you with much less effort.

It is Request-SPOPersonalSite. You can enqueue up to 200 OneDrive for Business sites at a time.

$emails = "user1@contoso.com,user2@contoso.com"
Request-SPOPersonalSite -UserEmails $emails

If you are going to do batches of 200 at a time, it is recommended to use the -NoWait switch.

Request-SPOPersonalSite -UserEmails $emails -NoWait


  • Hey Eric. Do you know if anything has changed? As of a few days ago, this command completes without error, but the one drive isn't provisioned any more. Any light you or anyone else can shed on this would be VERY helpful. – StraighterSwing Jan 12 '16 at 15:47
  • @StraighterSwing Not that I know of, I would say check back later and see if they provisioned as it is queued and throttled on the backend with everything else going on in the tenant. If all else fails, try opening a ticket with support, perhaps they broke something or a new management shell needs installed. – Eric Alexander Jan 12 '16 at 15:53
  • I've all but confirmed via MS support ticket there is a problem. I'll keep those interested posted with my progress with the MS support team. – StraighterSwing Jan 13 '16 at 18:34
  • I have been having this issue today as well. Using PowerShell to provision the sites does not fail, however, the sites are not created. If the user logs into the site normally, they get the start up site just fine and the site provisions for them. – ps_md Jan 14 '16 at 21:19
  • what was the outcome of this? Do you still have problems, I'm having some issues – Webfort Mar 1 '16 at 11:36

There are two errors on this Microsoft page.

  1. In addition to being an admin account, the account doing the provisioning MUST be licensed for SharePoint Online.
  2. The syntax of the PowerShell was incorrect in the original Microsoft page.  The emails should be EACH in quotes, separated by a comma ("mail1","mail2")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.