Disabling/Enabling Enties for CRM Mobile

In my prior post I showed how to query for entities that were enabled for mobile (tablet). Using that same query you can swap out the following for each loop to disable mobile for all entities

       foreach (var entity in results.EntityMetadata)
           Console.WriteLine("Entity {0}:{1}", 

           entity.IsVisibleInMobileClient = 
                new Microsoft.Xrm.Sdk.BooleanManagedProperty(false);

           UpdateEntityRequest updateEntity = 
                               new UpdateEntityRequest();

           updateEntity.Entity = entity;
           catch (Exception ex)
               Console.WriteLine("Could not update {0} - {1}",
                        entity.SchemaName, ex.Message);

It should be noted that you really can't disable ALL entities because the following are required to be left unchanged:
Activity, Team, Connection, Attachment, Entitlement, User, Web Resource, SLA KPI Instance, Note

And in case you get in trouble turning everything off and want to restore the original entities to being enabled - you can always use the filter on Schema name and provide the list - here's the condition for you :)

        string[] entityList = new string[] {
        entityFilter.Conditions.Add(new MetadataConditionExpression("SchemaName", 
            MetadataConditionOperator.In, entityList));

You can also easily use your own list to enable a whole bunch of entities all at once and not have to do them one by one in the UI. The metadata queries are flexible to you can also provide an exclude list simply by using the MetadataConditionOperator.NotIn operator.