0

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)

ERROR:

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:

$loader.CreatePersonalSiteEnqueueBulk(@("$user$Domain")) 

Error:

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.

cls
$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 = "[email protected]"
$password = ConvertTo-SecureString '*************' -AsPlainText -Force

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

Write-Host "Load website into cache" -ForegroundColor Yellow
$ctx.Load($web)
$ctx.ExecuteQuery()

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

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

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

2 Answers 2

1

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 = "[email protected],[email protected]"
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

https://technet.microsoft.com/en-us/library/dn792367.aspx

6
  • 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. Jan 12, 2016 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. Jan 12, 2016 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. Jan 13, 2016 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, 2016 at 21:19
  • what was the outcome of this? Do you still have problems, I'm having some issues
    – Webfort
    Mar 1, 2016 at 11:36
0

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 and acknowledge you have read our privacy policy.

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