Friday, September 4, 2015

My experience with O365 One Drive For Business and CreatePersonalSiteEnqueueBulk for Site Pre-Provisioning

If you want to pre provision one drive for business for every user in your organization, you need to implement a console application or a powershell script that will use SharePoint client object model in order to create users OneDrive for Business site collection.
In detail the method you need to use is CreatePersonalSiteEnqueueBulk of ProfileLoader class.

You need to pass to this method an array of string, each one will rapresent SharePoint online user's email.

Microsoft claims you can create a batch of max 200 users. Before execute another batch, you need to wait for previous batch completition (so you need to wait last user in batch one drive creation.)
No callback and no feedback are binded to this method. Simply ... wait.

In my experience, I've first tried with a 180 users batch but with no luck. Only first 8 users sites were created after 12 hours, while Microsoft claim max 5 minutes for user.

So my suggestion is to implement batch of only one user, call CreatePersonalSiteEnqueueBulk with this one item array, wait for one drive creation completition for that user and then execute next batch.

The method I've used to check one drive creation completition in c# is this simple snippet.

static bool OneDriveExistForUser(string userEmail, SharePointOnlineCredentials o365Cred)
    {
        bool retVal = false;
        string oneDriveURL = GetOneDriveUrlFromEmail(userEmail);
        HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(oneDriveURL);
        HttpWebResponse myHttpWebResponse;

        myHttpWebRequest.UseDefaultCredentials = true;
        myHttpWebRequest.Credentials = o365Cred;

        try
        {
   myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            if ((myHttpWebResponse.StatusCode == HttpStatusCode.OK) || (myHttpWebResponse.StatusCode == HttpStatusCode.Forbidden))
            {
               retVal = true;
      myHttpWebResponse.Close();
            }
        }
        catch (WebException httpWE)
        {
            if ((((System.Net.HttpWebResponse)httpWE.Response).StatusCode == HttpStatusCode.OK) || (((System.Net.HttpWebResponse)httpWE.Response).StatusCode == HttpStatusCode.Forbidden))
            {
               retVal = true;
            }
        }

        return retVal;
    }


The two parameters passed to the method are user's email and Office365 Credentials (must be at least SharePoint Admin of the tenant).

Good luck!

Tuesday, April 14, 2015

Re-Register APP in Windows 10 Technology Preview

I've recently upgraded my notebook to Windows 10 TP Build 10049 from previous build via windows update.
After upgrade completion no Appx can be started and even search is not working from start menu or from taskbar.


After a little research I've found a simple PowerShell script that re-register all Appx package of my installation.


The script, just in case you need it is split into two action.


First (all Shell Experience Packages):


Get-AppxPackage -all *shellexperience* -packagetype bundle |% {add-appxpackage -register -disabledevelopmentmode ($_.installlocation + “\appxmetadata\appxbundlemanifest.xml”)}


Second (for all other metro appx):


Get-AppxPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}


Thanks to this article by Robert Rulles that point me to the solution.

Monday, February 23, 2015

User Profile Synchronization Service Cannot Start with SQL Server 2014

Recently I've updated my SharePoint 2013 SQL Box to 2014 release version.
Everything in SharePoint seems to work as expected except User Profile Synchronization Service.

The service appear in stopped state, and if I try to start it, ULS trace this error:

ILM Configuration: Error 'ERR_CONFIG_DB'
UserProfileApplication.SynchronizeMIIS: Failed to configure MIIS post database, will attempt during next rerun. Exception: System.Configuration.ConfigurationErrorsException: ERR_CONFIG_DB

Fortunatly ther's a SharePoint Fix you can request to solve this issue.

The fix (KB 2760265) can be obtained here.

The installation of the fix is pretty fast and no reboot is required.
Configuration Wizard is not necessary after the installation.

Now you can re-enter your "User Profile Synchronization Service" credential and start the service.