SharePoint Online: Open Documents in Client Applications by Default

Requirement: Open documents in client applications by default in SharePoint Online.

How to Open Documents in Client Application in SharePoint Online?
SharePoint Online documents open in the browser instead of the client application? Well, by default documents such as Word, Excel, PowerPoint opens in browser with Office web apps in SharePoint Online. However, the Office web applications like Word Online don't give you full functionality as in the client installed application. So, if you want to change this behavior at site collection level, You have to activate a feature called "Open Documents in Client Applications by Default". Here is how to activate the feature:
  • Go to Site Settings >> Site Collection Features
  • Click on "Activate" button next to "Open Documents in Client Applications by Default" feature
    sharepoint online powershell open in client application
Activating the feature to open documents in client application for a single site collection is straight forward. How about activating the feature for all site collections?

SharePoint Online: PowerShell to Activate "Open in client application" Feature for All Sites
When the "Open Documents in Client Applications by Default" feature is activated, Office documents will open in the Office client application by default. E.g. a Excel spreadsheet will open in Microsoft Excel installed on the client computer. When this feature is deactivated, an Excel Spreadsheet will open in Office Web Applications within the web browser. Here is the PowerShell to set open documents in client application settings for all site collections in a tenant by activating the feature discussed above. 
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Function to Activate Feature in SharePoint Online
Function Activate-SPOFeature
    Param ($SiteURL,$FeatureGuid)
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credential.Username, $Credential.Password)
        $Ctx.Credentials = $Credentials
        #Get the Feature 
        $Feature =  $Site.Features.GetById($FeatureGuid)
        #Activate the feature if its not activated already
        Write-Host "Activating Feature $($FeatureStatus.DisplayName) in Site $SiteURL"
        if($Feature.DefinitionId -eq $null)
            #sharepoint online powershell open in client application
            $Site.Features.Add($FeatureGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) | Out-Null
            Write-Host "`t Feature Activated!" -ForegroundColor Green
            Write-host "`t Feature is Already Active on the Site collection!" -ForegroundColor Yellow
        write-host "Error Activating Feature: $($_.Exception.Message)" -foregroundcolor Red

#Parameters to Activate Feature
$AdminSiteURL = ""
$FeatureGuid= [System.Guid] ("8a4b8de2-6fd8-41e9-923c-c7c3c00f8295")

#Get Credentials to connect
$Credential = Get-Credential

#Connect To SharePoint Online Admin Center
Connect-SPOService -URL $AdminSiteURL -Credential $Credential
#Get All Site collection and loop through
ForEach($Site in (Get-SPOSite -Limit ALL))
    #Activate Feature
    Activate-SPOFeature -Site $Site.URL -FeatureGuid $FeatureGuid

PnP PowerShell to Enable Documents to Open in Client Application by Default
We can enable the feature that sets all documents to open in client application in a SharePoint Online site with PnP PowerShell as well:
$SiteURL = ""
$FeatureID= "8a4b8de2-6fd8-41e9-923c-c7c3c00f8295" #Open Documents in Client Applications by Default
#Connect to SharePoint Online site
Connect-PnPOnline $SiteURL -UseWebLogin

#Get the Feature
$Feature = Get-PnPFeature -Scope Site -Identity $FeatureID
#Get the Feature status
If($Feature.DefinitionId -eq $null)
    #Activate the Feature
    Enable-PnPFeature -Identity $FeatureID -Scope Site
    Write-host -f Green "Feature Activated Successfully!"
    Write-host -f Yellow "Feature is already activate!"

SharePoint Online: Configure Open in Client Application at Document Library Level
In SharePoint Online, you can configure the open document in browser or client application setting from the document library's settings.
  • Navigate to the Document Library >> Click on Settings gear >> Library Settings from the menu.
  • Under General Settings, Click on "Advanced Settings" link
  • Under "Opening Documents in the Browser", choose "Open in the client application" or " Open in the browser" according to your requirement.
    sharepoint online open documents in client applications by default
This overrides the setting applied at the site collection level and open documents in client application instead of the browser.


  1. This script has just what we need (and seems to be the only one with the solution) but when we run it we get this error on every site: Error Activating Feature: Exception calling ".ctor" with "2" argument(s): "The 'username' argument cannot be null.
    Parameter name: username". Has something in SharePoint Online changed since this script was created?

    1. Script updated to get credentials. Try now!

    2. The above settings are not working in Chrome or Firefox.Any seetings to do with chrome

  2. Thanks so much for this Salaudeen ! But it doesn't work for MFA enabled environments. I'm getting this error

    Connect-SPOService : The sign-in name or password does not match one in the Microsoft account system.
    At line:55 char:1
    + Connect-SPOService -URL $AdminSiteURL -Credential $Credential
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Connect-SPOService], IdcrlException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService

    1. On MFA enabled environments, You can simply remove the "Credential" parameter from Connect-SPOService cmdlet, and you'll get a authentication prompt with MFA support. So, instead of:

      Connect-SPOService -URL $AdminSiteURL -Credential $Credential

      Connect-SPOService -URL $AdminSiteURL

      You can refer this post: Handling MFA in SharePoint Online PowerShell scripts

  3. Why don't we have any method in SharePoint Online to Configure Open in Client Application at Document Library Level using CSOM?

  4. I am trying to accomplish the same function using Enable-PnPFeature

    Enable-PnPFeature -Identity "8a4b8de2-6fd8-41e9-923c-c7c3c00f8295

    Any ideas why it might not be working?

    1. Use the "Scope" Parameter as "Site" in the cmdlet: Enable-PnPFeature -Identity $FeatureID -Scope Site

  5. Is there a way to do this through Power Automate using the REST API?


Please Login and comment to get your questions answered!

Powered by Blogger.