Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. SharePoint Client Components: 16.0.4002.1211
  2. MS Online Services Sign-In Assistant: 7.250.4556.0
  3. Azure AD Module for Windows: 1.0.0 **(I don't think this one is needed)**
  4.  
  5. $loader =[Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($ctx)
  6.  
  7. 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"."
  8.  
  9. $loader.CreatePersonalSiteEnqueueBulk(@("$user$Domain"))
  10.  
  11. One Drive Not Provisioned Method invocation failed because [Microsoft.SharePoint.Client.UserProfiles.ProfileLoader] does not contain a method named 'CreatePersonalSiteEnqueueBulk'.
  12.  
  13. cls
  14. $Domain = "@mydomain.com"
  15.  
  16. Write-Host "Load SharePoint and One Drive Assemblies" -ForegroundColor Yellow
  17. $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
  18. $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
  19. #Must be SharePoint Administrator URL
  20. $webUrl = "https://SiteDomain-admin.sharepoint.com"
  21. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
  22.  
  23. Write-Host "Create Connection To Administration Site" -ForegroundColor Yellow
  24. $web = $ctx.Web
  25. $username = "me@myDomain.com"
  26. $password = ConvertTo-SecureString '*************' -AsPlainText -Force
  27.  
  28. $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$password )
  29.  
  30. Write-Host "Load website into cache" -ForegroundColor Yellow
  31. $ctx.Load($web)
  32. $ctx.ExecuteQuery()
  33.  
  34. $loader =[Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($ctx)
  35.  
  36. #To get the profile
  37. $profile = $loader.GetUserProfile()
  38. $ctx.Load($profile)
  39. $ctx.ExecuteQuery()
  40. #$profile
  41.  
  42. Write-Host "Loading User Array" -ForegroundColor Yellow
  43. $UserArray = "User1", "User2", "User3","User4"
  44. Foreach ($user in $UserArray)
  45. {
  46. try{
  47. #To queue up the profile
  48. $loader.CreatePersonalSiteEnqueueBulk(@("$user$Domain"))
  49. $loader.Context.ExecuteQuery()
  50. Write-Host "$user One Drive Provisioned" -ForegroundColor Cyan
  51. }catch{
  52. Write-Host "$user One Drive Not Provisioned" $_.Exception.Message -ForegroundColor Red
  53. }
  54. }
  55. Write-Host "COMPLETED" -ForegroundColor Green
  56.  
  57. $emails = "user1@contoso.com,user2@contoso.com"
  58. Request-SPOPersonalSite -UserEmails $emails
  59.  
  60. Request-SPOPersonalSite -UserEmails $emails -NoWait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement