Configure

Open Office documents in the Client

Ensure that office documents will open in the desktop client application if such is installed

Summary

One of the most common requests from customers is that any office document in SharePoint site should open in the desktop client application so here goes:

Implementation

  • Open VS Code
  • Create a new file
  • Write a script as below
  • Change the variables to target to your environment
  • Run the script

Screenshot of Output

Example Screenshot

powershell

# SharePoint online site url
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Scope of feature: Web or Site
$featureScope = "Site"

# SharePoint Feature ID: in this case "Open Documents in Client Applications by Default (OpenInClient)"
$featureId = "8a4b8de2-6fd8-41e9-923c-c7c3c00f8295"	

# Another common scenario is Activating Document ID feature (Feature ID: b50e3104-6812-424f-a011-cc90e6327318)

# Connect to SharePoint Online site
Connect-PnPOnline -Url $siteUrl -Interactive

# Get Feature from SharePoint site
$spFeature = Get-PnPFeature -Scope $featureScope -Identity $featureId

# Check if feature found or not
if ($spFeature.DefinitionId -eq $null) {  
    Write-host "Activating Feature ($featureId)..." 
	
    # Activate the site feature
	Enable-PnPFeature -Scope $featureScope -Identity $FeatureId -Force
 
    Write-host -f Green "Feature ($featureId) has been activated Successfully!"
}
else {
    Write-host "Feature ($featureId) is already active on this site!"
}   
   

Contributors

Author(s)
Kasper Larsen, Fellowmind
Ganesh Sanap

Disclaimer

THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

Tool documentation & references

Keep exploring