Thursday, April 17, 2014

SharePoint : Open documents in browser for Office Web Apps using PowerShell

Recently we configured Office Web Apps in a SharePoint 2013 farm. But it didn’t work for most of the site collections as office documents were downloading instead of opening in the browser.

image

This is because it is set to open documents in client application. You can see it in the library settings in each document library.

image

If we change the setting back to “Open in the browser”, documents will open in Office Web Apps as expected. Is there any easier way to do the change for every site instead of change it at library level?

Luckily there is an easier way. The Open in client application behavior is enabled by a site collection feature.

image

If we deactivate the feature the setting will revert back to “Open in the browser” option.

We used following PowerShell to deactivate above feature for all site collections in the farm

  1. $clientFeature = "8A4B8DE2-6FD8-41e9-923C-C7C3C00F8295"
  2.  
  3. Get-SPSite -WebApplication "http://525256-wfe2013:5003/" -limit ALL | ForEach-Object {
  4. if ($_.Features[$clientFeature] -ne $null) {
  5.    Disable-SPFeature -Identity $clientFeature -url $_.URL -Confirm:$false
  6. }
  7. }

That’s all we have to do

image

No comments: