简体   繁体   中英

How to hide a SharePoint tab on 100 sites? (SP2010)

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.

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 ".

PS 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM