Fix: SharePoint 2010 Left Navigation(QuickLaunch) Items that are not visible

Hi,

If you have a problem that you can not access or see any object programmatically in your code or powershell script you might be able to go around this problem. In my case annoyingly SharePoint showed navigational items in the Quick Launch UI management page(items like sites) BUT once I tried to access items through code and hide them I could not see any items at all.

What I did was to re-activate the site level SharePoint out of the box publishing feature that enables publishing functionalities. After this SP did some “magic” behind the scenes and I was able once again to access navigational items and hide them using the ExcludeFromNavigation publishing method.

WARNING: Before you execute the script below OR decide to re-active the OTB Publishing feature take notice that doing so may have unexpected effects in your environment. Test this well before applying to a production environment.

PortalNavigation.ExcludeFromNavigation Method

Below is a sample script that will do what I just described:

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

 

$siteURL = “Your site URL”

 

$spSite = [Microsoft.SharePoint.SPSite] ($siteURL)

 

if($spSite -ne $null)

{

                $web = $spSite.OpenWeb()

                if($web -ne $null)

                {

                                Disable-SPFeature -URL $siteURL -Identity PublishingWeb -Force

                                Enable-SPFeature -URL $siteURL -Identity PublishingWeb

                                if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))

                                {

                                                $spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

                                                if($spPubWeb -ne $null)

                                                {

                                                                foreach($subWeb in $web.Webs)

                                                                {

                                                                                if($subWeb -ne $null)

                                                                                {

                                                                                                $spPubWeb.Navigation.ExcludeFromNavigation($false, $subWeb.ID)

                                                                                                $subWeb.Dispose()

                                                                                }

                                                                }

                                                }

                                }

                                $spPubWeb.Update()

                }

 

   $web.Dispose()

   $spSite.Dispose()

}

else

{

   Echo $siteURL “does not exist, check the site collection url”

}

Echo Finish

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s