I have a site collection without the publishing feature activated (Id: f6924d36-2fa8-4f0b-b16d-06b7250180fa).
I want to activate it, but it fails :
Enable-SPFeature : The field with Id {51d39414-03dc-4bd0-b777-d3e20cb350f7} defined in feature {aebc918d-b20f-4a11-a1db-9ed84d79c87e} was found in the current site collection or in a subsite.
After some digging, I discover that one of the subsite already have the columns of the publishing features. Thus, the feature activation can't create the column.
If I try to -Force
the activation, it does not fail, but the columns are not created.
How can I properly enable the feature at the top level site, without breaking the subsites ?
FYI :
- Feature with Id {aebc918d-b20f-4a11-a1db-9ed84d79c87e} is "PublishingResources", a hidden feature
- Field with Id {51d39414-03dc-4bd0-b777-d3e20cb350f7} is "PublishingStartDate". It's the first field defined in the feature PublishingResources
- {f6924d36-2fa8-4f0b-b16d-06b7250180fa} is the Id of the publishing feature.
[Edit] After some search, I was able to activate the feature using this script :
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
$urlSite = "http://server/sitecollection"
$urlSubWeb = "http://server/sitecollection/subweb"
$tempPath = "d:\temp"
$featId = "f6924d36-2fa8-4f0b-b16d-06b7250180fa" # Publishing feature
# Backup the site collection in case something goes wrong
Backup-SPSite -Identity $urlSite -Path "$tempPath\sitecoll.bak"
Export-SPWeb -Identity $urlSubWeb -Path "$tempPath\subweb.cmp" -IncludeUserSecurity -IncludeVersions All
# Delete all subwebs. Error "Cannot delete top-level" can be ignored
Get-SPWeb -Site $urlSite | Sort-Object -Descending Url | Remove-SPWeb -confirm:$false
Enable-SPFeature -Identity $featId -Url $urlSite
New-SPWeb -Url $urlSubWeb -Language 1033
Import-SPWeb -Identity $urlSubWeb -Path "$tempPath\subweb.cmp" -IncludeUserSecurity
Please note that this scripts works, because I have only one subweb at the root, and this is the one which defines the columns. A more complex script should be written if topology is different.
Unfortunately, when I try to instantiate a new subweb using Enterprise Wiki template, I get a similar error :
InitializePublishingWebDefaults failed. System.InvalidOperationException: Failed to compare two elements in the array. ---> System.ArgumentException: Invalid field name. {b510aac1-bba3-4652-ab70-2d756c29540f} /sitecollection/_catalogs/masterpage