One of our clients reported an issue while editing the home page of SharePoint portal.
Error: “An Unexpected Error Occurred”
Impact: Unable to save the changes made.
Reason Provided by the customer: Power User tried to deactivate and activate the publishing feature.
Team tried reactivating the publishing feature which caused more pain. The Navigation bar was broken in the home page. (Expected SP 2010 Behavior).
Fix: Activate SP 2010 Publishing Feature using PowerShell (Force it with Proper Bag Parameter)
1. Installed SharePoint Manager 2010
2. Explored the property bag to identify the TRUE value of Publishing Feature
3. Though the User Interface shows the feature as ACTIVATED and PowerShell output gave the same result. But, the knot is the [“__PublishingFeatureActivated”] was set to FALSE in property bag.
4. No option to right click to activate (Sounds More Cranky) – But no other go, I took a chance to implement the below PowerShell code.
#Solution: SharePoint 2010 - PowerShell
#To activate the publishing feature in SP2010 portal
[System.Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null
$site = Get-SPSite "http://www.yourportal.com/"
$web = $site.openweb()
#If SP 2010 fails to read the __PagesListsID (Internal Name). I prefer to do the below
$web = get-spweb "http://www.yourportal.com/"
$correctId = $web.Lists["Pages"].ID
$web.AllProperties["__PagesListId"] = $correctId.ToString()