Sandeep Khandelwal's Blog

SharePoint, ASP.net & other related stuffs

How to remove a tab from all the sites in a web application

clock August 30, 2011 12:25 by author Sandeep Khandelwal

Recently, I had a need to basically remove “Home” tab from global navigation for all the sites (Site collections) in a web application. Here is a quick code snippet that basically does that.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Navigation;
namespace GlobalNavigationRemove
{
    class Program
    {
        static void Main(string[] args)
        {
            string webAppUrl = string.Empty;
            int iCounter = 0;
            int iNbrOfSites = 0;
            if (args.Length > 0)
            {
                Console.WriteLine(string.Format("Web Application: {0}", args[0]));
                webAppUrl = args[0].ToString();
                if (args.Length > 1)
                {
                    Console.WriteLine(string.Format("Test Iteration: {0}", args[1]));
                    iNbrOfSites = int.Parse(args[1].ToString());
                }
            }
            SPWebApplication webApp = SPWebApplication.Lookup(new Uri(webAppUrl));
            Console.WriteLine(string.Format("Total Site collections detected: {0}" , webApp.Sites.Count.ToString()));
            Console.WriteLine(string.Format("*************************************Starting the removal ********************************"));
               
                foreach (SPSite siteCollection in webApp.Sites)
                {
                    if (iCounter > iNbrOfSites && iNbrOfSites != 0)
                    {
                        return;
                    }                   
                    PublishingWeb myPublishingWeb = PublishingWeb.GetPublishingWeb(siteCollection.OpenWeb());
                    Console.WriteLine(string.Format("Now Processing : {0}", myPublishingWeb.Title));
                    SPNavigationNodeCollection publishingNavigationNodes = myPublishingWeb.Navigation.GlobalNavigationNodes;
                    try
                    {
                        SPWeb web = siteCollection.OpenWeb();
                        SPNavigationNodeCollection webNavigationNodes = web.Navigation.TopNavigationBar;
                       

                        foreach (SPNavigationNode node in webNavigationNodes)
                        {
                            if (node.Title.Trim().ToLower() == "home")
                            {
                                node.Delete();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(string.Format("Exception Occurred while processing site {0} \n\n", ex.ToString()));
                    }
                    iCounter++;

            }
        }
    }
}

Currently rated 3.3 by 6 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


OffWfCommon feature not installed

clock August 30, 2011 10:40 by author Sandeep Khandelwal

Recently, I was trying to create a new site collection of type “Publishing” but I get kept the following errors.

Dependency feature with id c9c9515d-e4e2-4001-9050-74f980f93160 for feature 'ExpirationWorkflow' (id: c85e5759-f323-4efb-b548-443d2216efb5) is not installed.

On a quick bing search, the feature id c9c9515d-e4e2-4001-9050-74f980f93160  corresponds to “OffWFCommon” feature. So, I went to my 14 hive and did a quick lookup. To my surprise, the feature files were already in the file system. Now, instead of trying to figure out why this happened, I just wanted to move on with my project. So, I ran the following powershell command. This command basically, re-attaches the orphaned features in feature folder.

INSTALL-SPFEATURE -PAth "OffWFCommon"

 

And Voila, now, I was able to create my test publishing site just fine. Hope this helps someone else.

image

Currently rated 3.2 by 6 people

  • Currently 3.166667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


How to activate a feature in all the site collections in a web app

clock August 24, 2011 10:13 by author Sandeep Khandelwal

Here is the code snippet that will help.

$webAppUrl = "<yourWebAppUrl>"
$webapp = Get-SPWebApplication $webAppUrl  | Get-SPSite -Limit All | Get-SPSite -limit all | ForEach-Object {Enable-SPFeature -Identity 'Your feature guid'  -Url $_.Url}

Recently, I had to create this PowerShell command to activate branding features to all the existing site collections.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


How to move a Central Administration site from Web Server to App Server.

clock August 16, 2011 11:56 by author Sandeep Khandelwal

Moving a central administration site to another sever in the same farm is essentially a two part process. Part I, where all the steps are performed in the source server (current server hosting your Central Administration website) and Part II comprises of steps to provision new Central Administration site on the destination server (future home of Central Administration site).

Part I

Step 1) On Source server, run the products and configuration wizard.

image

Click on Next > button.

Step 2) Click Yes to the following screen.

image

Step 3) Ensure that you have “Do not disconnect from the server farm” selected.

image

** Do not select “Disconnet from the server farm” This will essentially delete all the web applications, which is probably not something that you want.

Step 4) Select “Yes, I want to remove the website from this machine”. This step is really important.

image

Step 5) Ensure that “Host the central Administration web application” is showing status = “no”.

image

This completes the part 1 of moving the central administration site to another server in the farm.

Part II

Now, log in to the “new” or destination server that will host the Central Administration site. Run the products and configuration wizard.

image

Step 2)

Ensure that you select “Do not disconnect from this server farm”

image

Step 3) Now, provide your preferred port number and Authentication methods.

image

Click Next.

Step 4) Ensure that “Host the Central Adminsitration Web Application” shows “Yes”

image

A

At this point the configuration will start.

image

image

That’s it. You have successfully moved your Central Administration site to another server.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


About the author

I work as SharePoint Consultant and Lead ECM Solution Expert for Integration Now (a pioneer in SharePoint solutions in midwest region). Besides having PMP, MCP, MCTS and other technical certifications, I am also an MBA (Finance) from UMKC. I lead & oversee SharePoint engagements in 4 states around Kansas City (MO, KS, IA, & NE).

Tag cloud

Page List

Sign in