Hi @Andy Kilgore
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.