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.
Below is a sample script that will do what I just described:
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=220.127.116.11, 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
$spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
if($spPubWeb -ne $null)
foreach($subWeb in $web.Webs)
if($subWeb -ne $null)
Echo $siteURL “does not exist, check the site collection url”