Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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    
share|improve this question

1 Answer 1

up vote 0 down vote accepted

A bit ugly, but here is a full working script that solved the problem and create my wiki site (which was actually my first goal):

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0

$urlSitecol = "http://server/sitecoll"
$urlsubweb = "http://server/sitecoll/subweb"
$tempPath = "d:\temp"
$featId = "f6924d36-2fa8-4f0b-b16d-06b7250180fa"
$urlWiki = "http://server/sitecoll/subweb/wiki"


Backup-SPSite -Identity $urlSitecol -Path "$tempPath\sitecoll.bak"

Export-SPWeb -Identity $urlsubweb -Path "$tempPath\subweb.cmp" -IncludeUserSecurity -IncludeVersions All

$site = Get-SPSite $urlSitecol
$owner = $site.Owner

Remove-SPSite -Confirm:$false -Identity $urlSitecol

New-SPSite -Url $urlSitecol -OwnerAlias $owner -Language 1033 -Template "STS#1"


Enable-SPFeature -Identity $featId -Url $urlSitecol

New-SPWeb -Url $urlsubweb -Language 1033

Import-SPWeb -Identity $urlsubweb -Path "$tempPath\subweb.cmp"  -IncludeUserSecurity

New-SPWeb -Url $urlWiki -Language 1036 -Template "ENTERWIKI#0".

This script works because the top level site was empty... If it had content, it would have been far more complex.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.