Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)**
- $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"."
- $loader.CreatePersonalSiteEnqueueBulk(@("$user$Domain"))
- One Drive Not Provisioned Method invocation failed because [Microsoft.SharePoint.Client.UserProfiles.ProfileLoader] does not contain a method named 'CreatePersonalSiteEnqueueBulk'.
- 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 = "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
- $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
- $emails = "user1@contoso.com,user2@contoso.com"
- Request-SPOPersonalSite -UserEmails $emails
- Request-SPOPersonalSite -UserEmails $emails -NoWait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement