Elenca le feature installate nella farm SharePoint 2007 / 2010 visualizzando: scope, id, nome directory, solution id, solution file e titolo della solution localizzato in inglese (1033)

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace ElencoFeatures
{
  class Program
  {
    private static System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(1033);  //mettere 1040 x italiano
    
    static void Main(string[] args)
    {
      SPFarm farm = SPFarm.Local;

      foreach (var item in farm.FeatureDefinitions)
      {
        string solutionName = "";
        try
        {
          SPSolution sol = farm.Solutions[item.SolutionId];
          solutionName = sol.Name;
        }
        catch (Exception) { }

        Console.WriteLine(string.Format("{0};{1};{2};{3};{4};{5}"
           , item.Scope, item.Id
           , item.DisplayName, item.SolutionId
           , solutionName, item.GetTitle(ci)));
      }
    }
  }
}
Per le console application SharePoint ricordati di impostare la compilazione Platform Target a Any CPU

da un output simile al seguente

Text

Farm;001f4bd7-746d-403b-aa09-a6cc43de7942;PublishingStapling;00000000-0000-00000000-000000000000;;Publishing Features Stapling
Site;00bfea71-1c5e-4a24-b310-ba51c3eb7a57;BasicWebParts;00000000-0000-0000-0000000000000000;;Basic Web Parts
Web;00bfea71-1e1d-4562-b56a-f05371bb0115;XmlFormLibrary;00000000-0000-0000-0000000000000000;;XML Form Libraries
Web;00bfea71-2062-426c-90bf-714c59600103;LinksList;00000000-0000-0000-0000-00000000000;;Links Lists
...
Web;2f2d82ab-5425-489a-9ccd-470f4ed561de;Reservations;82E3DDD3-9E6D-4879-B9EA-202F10FB55DB;reservations.wsp;New Reservations
...
Tags:
C#236 SharePoint498 SharePoint 2007218 SharePoint 2010224
Potrebbe interessarti anche: