tags:

views:

49

answers:

1

I have 100 team sites in SharePoint 2010. At the last minute, I have been asked to hide a tab on each of these sites. Through the GUI, I could do this by using the Navigation option under Site Settings, but I would have to do it for all 100 sites. Is there a way to do this programmatically? Or globally through the GUI (I doubt this is an option)? I have tried using JQuery, but due to the lag, it is not a viable option. I figured there may also be the possibility to write a powershell script to do this - I am just still new to powershell.

Thoughts? Thanks.

+1  A: 

You should use something like this in your Console application:

SPSite site = new Site("http://yoursite");
foreach (SPWeb web in site.AllWebs)
{
    foreach(SPNavigationNode node in web.Navigation.TopNavigationBar)
    {
        if (node.Title == "Test")
        {
            node.IsVisible = false;
            node.Update();
        }
    }
    web.Dispose();
}
site.Dispose();

This script will hide all nodes with title "Test". You can also use Url property to determine if the node needs to be hidden.

Here I expect, that you need to change navigation of 100 child webs in site collection "http://yoursite".

P.S. Please, make sure, that you target .Net Framework 3.5 in your Console App, and AnyCPU platform is specified in Visual Studio project properties. Or you can get errors saying that your site not found.

omlin