So I’ve got a SharePoint site that is optimised for viewing in mobile browsers, problem is that OOTB SharePoint is trying to show the fugly “mobile view”. Now Waldek has a post about just this problem, in my case I’ve decided that his first offered work around is perfectly acceptable for my scenario.
Now if you haven’t worked it out yet I also have a requirement that my deployments must be 100% repeatable and driven my PowerShell. So I need to modify the web.config file via PowerShell, enter a helpful post from the Script Guy blogs.
From there it wasn’t too hard to create my own script:
#Disable Mobile Redirection for all browsers for a given web application
param( [Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)]
[Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]
$WebApplication)
# SharePoint cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell
if([Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")-eq$null){throw "Unable to load Microsoft.SharePoint.dll";}
$WebApp = $WebApplication.Read()
$configMod1 = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$configMod1.Path = "configuration/system.web"
$configMod1.Name = "browserCaps"
$configMod1.Value = '<browserCaps><result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /><filter>isMobileDevice=false</filter></browserCaps>'
$configMod1.Sequence = 0
$configMod1.Owner = "contoso\administrator"
## SPWebConfigModificationType.EnsureChildNode -> 0
$configMod1.Type = 0
$WebApp.WebConfigModifications.Add( $configMod1 )
$WebApp.Update()
$WebApp.Parent.ApplyWebConfigModifications()
Remove-PsSnapin Microsoft.SharePoint.PowerShell
I highly recommend that you read both the blogs I linked above, it’s articles like those that enable me to stand on the shoulders of giants to achieve my ends
