SharePoint Online: How to do a bulk creation of ODFB Sites using PowerShell!

One of the new features added by Microsoft over the past year to the client object model (CSOM) SharePoint is the possibility of doing massive and asynchronous provisioning of OneDrive To Business (ODFB) sites using the CreatePersonalSiteEnqueueBulk () method of the class ProfileLoader defined in Microsoft.SharePoint.Client.UserProfiles.dll assembly of the CSOM. This method simply requires an array of strings with the e-mails of the Office 365 users we want to be provision ODFB sites as you can see in the script that I created about:  How to do a bulk creation of OneDrive For Business sites in Office 365

############################################################################################################################################

#Script that allows to asynchronously provision OneDrive For Business for a set of users

# Required Parameters:

#  -> $sCSOMPath: Path for the Client Side Object Model for SPO.

#  -> $sUserName: User Name to connect to the SharePoint Online Site Collection.

#  -> $sPassword: Password for the user.

#  -> $sSiteUrl: SharePoint Online Administration Url.

#  -> $ODFBUser: Office 365 user .

############################################################################################################################################

 

$host.Runspace.ThreadOptions = "ReuseThread"

 

#Definition of the function that allows to provision ODFB for a set of users

function Create-ODFBSite

{

    param ($sCSOMPath,$sSiteUrl,$sUserName,$sPassword,$sODFBUsers)

    try

    {    

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

        Write-Host "Getting the User Profile Information for current user" -foregroundcolor Green

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

                    

        #Adding the Client OM Assemblies

        $sCSOMRuntimePath=$sCSOMPath +  "\Microsoft.SharePoint.Client.Runtime.dll"  

        $sCSOMUserProfilesPath=$sCSOMPath +  "\Microsoft.SharePoint.Client.UserProfiles.dll"        

        $sCSOMPath=$sCSOMPath +  "\Microsoft.SharePoint.Client.dll"             

        Add-Type -Path $sCSOMPath         

        Add-Type -Path $sCSOMRuntimePath

        Add-Type -Path $sCSOMUserProfilesPath

 

        #SPO Client Object Model Context

        $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteUrl) 

        $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUserName, $sPassword)  

        $spoCtx.Credentials = $spoCredentials        

        $spoUserProfilesLoader=[Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($spoCtx)     

        $spoUserProfilesLoader.CreatePersonalSiteEnqueueBulk($sODFBUsers)

        $spoUserProfilesLoader.Context.ExecuteQuery()

        $spoCtx.Dispose()

    }

    catch [System.Exception]

    {

        write-host -f red $_.Exception.ToString()   

    }    

}

 

#Required Parameters

$sSiteUrl = "https://<SPO_Site_Url>/" 

$sUserName = "<SPOUser>@<SPO_Domain>.onmicrosoft.com" 

$sPassword = Read-Host -Prompt "Enter your password: " -AsSecureString

$sCSOMPath="<CSOM_Path>"

$sODFBUsers="<SPOUser1>@<SPO_Domain>.onmicrosoft.com","<SPOUser2>@<SPO_Domain>.onmicrosoft.com"

 

Create-ODFBSite -sCSOMPath $sCSOMPath -sSiteUrl $sSiteUrl -sUserName $sUserName -sPassword $sPassword -sODFBUsers $sODFBUsers

To verify that the ODFB sites have been provisioned I recommend the following post of Thomas Balkeståhl: http://blog.blksthl.com/2014/08/08/office-365-guide-series-verify-provisioned-onedrives-using-powershell/

Un pensamiento en “SharePoint Online: How to do a bulk creation of ODFB Sites using PowerShell!

  1. Pingback: SharePoint 2013: Resumen de posts (LXIV)! | Pasión por la tecnología...

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s