Disable SharePoint Mobile View with PowerShell

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

A client recently had a request to disable the mobile view feature of SharePoint 2010. Fortunately, Jeremy Thake has written an excellent article on this already – How We Did It – Mobile View. We tested the second option and decided to go with that approach. The only problem was that I wasn’t keen on editing 10 web.config files.

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Again, PowerShell comes to the rescue! I discovered that we could make web.config changes with the SharePoint object model, and therefore have all configurations updated at once. Special thanks to Farhan Faiz for his blog entry: SharePoint 2010: PowerShell script to add in web.config.

$webApp = Get-SPWebApplication http://portal.company.com
$configMod = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$configMod.Path = "configuration/system.web"
$configMod.Name = "browserCaps"
$configMod.Sequence = 0
$configMod.Type = 0
$configMod.Value = "<browserCaps> </browserCaps>"
 
$configMod1 = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$configMod1.Path = "configuration/system.web/browserCaps"
$configMod1.Name = "result"
$configMod1.Sequence = 0
$configMod1.Type = 0
$configMod1.Value = "<result type=""System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a""/><filter>isMobileDevice=false</filter>"
 
$webApp.WebConfigModifications.Add($configMod)
$webApp.WebConfigModifications.Add($configMod1)
$webapp.Update()
$webapp.Parent.ApplyWebConfigModifications()
$webapp.WebConfigModifications.Clear()

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

2 thoughts on “Disable SharePoint Mobile View with PowerShell”

  1. Hi Peter, I was just look at your blog on the subject of Mobile views – once I run this powershell script to disable the Mobile view – are the changes easily reversed at a later stage?

    cheers,
    Brad

    1. Hi Brad,

      In short, yes you can reverse the changes.

      Jeremy’s article (option 2) shows how you can make the change manually, so to reverse the changes simply remove the block from the web.config file.

      As with any script, I would suggest trying this in a test environment, and backup your web.config files prior to execution.

      Cheers,
      Peter

Leave a Reply

Your email address will not be published. Required fields are marked *