question

AndyKilgore-8416 avatar image
0 Votes"
AndyKilgore-8416 asked YiLu-MSFT commented

O365 Sharepoint - Set Default Behaviour Open with Client Apps

I know on a per-site basis we can do the following:
At the document library level, we could go to Library settings>Advanced settings>Open in the client application:

134707-image.png

Then go to Site information>View all site settings>Site Collection features> activate the feature as shown below:
134769-image.png


But how can I do this:
A) Globally to all existing sites/libraries
B) As the default for newly created sites/libraries


I tried with

 Connect-PnPOnline $SiteURL
 $FeatureID = "8a4b8de2-6fd8-41e9-923c-c7c3c00f8295"
 Enable-PnPFeature -Identity $FeatureID -Scope Site

Although this completes without error the it only updates the later section for the collection and also it doesn't help me default this decision for new objects.



office-sharepoint-online
image.png (15.3 KiB)
image.png (10.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YiLu-MSFT avatar image
0 Votes"
YiLu-MSFT answered YiLu-MSFT commented

Hi @AndyKilgore-8416
To globally activate “Open Documents in Client Applications by Default” feature on all existing sites of the tenant, you could can use the following code.

 #Parameters
 $TenantAdminURL = "https://Crescent-Admin.SharePoint.com"
 $FeatureId = "8a4b8de2-6fd8-41e9-923c-c7c3c00f8295" #"Following Content" Web Scoped Feature
      
 #Function to Activate a Web Feature in SharePoint Online
 Function Activate-PnPWebFeature
 {
     [cmdletbinding()]
     Param(
         [parameter(Mandatory = $true, ValueFromPipeline = $True)] $Web,
         [parameter(Mandatory = $true, ValueFromPipeline = $False)] $FeatureId
     )
      
     Try {
         Write-host -f Yellow "Trying to Activate Feature on:"$web.Url
         #Get the Feature to activate
         $Feature = Get-PnPFeature -Scope Web -Identity $FeatureId -Web $Web -Connection $SiteConn -ErrorAction Stop
      
         #Check if the Feature is Activate
         If($Feature.DefinitionId -eq $null)
         {
             #Activate the feature
             Enable-PnPFeature -Scope Web -Identity $FeatureId -Force -Web $Web -Connection $SiteConn -ErrorAction Stop
             Write-host -f Green "`tFeature Activated Successfully!"
         }
         Else
         {
             Write-host -f Cyan "`tFeature is already active!"
         }
     }
     Catch {
         write-host "`tError Activating Feature: $($_.Exception.Message)" -foregroundcolor Red
     }
 }
      
 #Connect to Admin Center
 $Cred = Get-Credential
 Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
      
 #Get All Site collections - Exclude: Seach Center, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites
 $SitesCollections = Get-PnPTenantSite | Where -Property Template -NotIn ("SRCHCEN#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")
      
 #Loop through each site collection
 ForEach($Site in $SitesCollections)
 {
     #Connect to site collection
     $SiteConn = Connect-PnPOnline -Url $Site.Url -Credentials $Cred
      
     #Call the Function for Web & all Subwebs
     Get-PnPWeb -Connection $SiteConn | Activate-PnPWebFeature -FeatureId $FeatureId
     Get-PnPSubWebs -Connection $SiteConn -Recurse | ForEach-Object { Activate-PnPWebFeature $_ -FeatureId $FeatureId}
      
     Disconnect-PnPOnline -Connection $SiteConn 
 }

As to the second requirement, currently we could not activate the feature as the default for newly created sites/libraries.


If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for this improved code from what I was using.

I notice this activates the same PNP feature in Image#2, is image#1 superseded by this decision and made irrelevant?

0 Votes 0 ·
YiLu-MSFT avatar image YiLu-MSFT AndyKilgore-8416 ·

Hi @AndyKilgore-8416
Image#1 is still important, if you activate “Open Documents in Client Applications by Default” feature, then choose "open in the browser", the documents in the library will still be open in the browser.

What's more, the third option will be changed like this:

135697-image.png


0 Votes 0 ·
image.png (8.7 KiB)