Skip to content

Instantly share code, notes, and snippets.

@sandromello
Created September 17, 2015 21:04
Show Gist options
  • Save sandromello/96e519dd6d92181923fb to your computer and use it in GitHub Desktop.
Save sandromello/96e519dd6d92181923fb to your computer and use it in GitHub Desktop.
Create Site OneDrive - Office365
$loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
$loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles")
#Must be SharePoint Administrator URL
$webUrl = "https://domain-admin.sharepoint.com"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$web = $ctx.Web
$username = "[email protected]"
write-host "Digite sua senha"
#Cae1ein8
$password = read-host -AsSecureString
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$ctx.Load($web)
$ctx.ExecuteQuery()
$loader =[Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($ctx)
#To Get Profile
$profile = $loader.GetUserProfile()
$ctx.Load($profile)
$ctx.ExecuteQuery()
$profile
#To enqueue Profile
$loader.CreatePersonalSiteEnqueueBulk(@("conta@dominio"))
$loader.Context.ExecuteQuery()
Write-Host "COMPLETED"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment