Custom PowerShell Commands

on Monday, November 23, 2009

To Create Custom Cmdlet, Your class can inherit from either PSCmdlet or Cmdlet class.

You could override below methods.
BeginProcessing-- Provides optional one-time, preprocessing functionality for the cmdlet.
ProcessRecord -- Provides record-by-record processing functionality for the cmdlet. It may be called any number of times or not at all, depending on the input of the cmdlet.

EndProcessing Provides optional one-time, post-processing functionality for the cmdlet.
StopProcessing Stops processing when the user stops the cmdlet asynchronously, such as by entering the key combination Ctrl+C.

To register this cmdlet you need to create a custom SnapIn by inheriting from PSSnapIn or CustomPSSnapin
You have to override below property.
Description: Supply short description of your Snap-in here.

Name: Supply name of your Snap-in here.
Vendor: Supply vendor information for your Snap-in here.
Cmdlets: This is where you provide collection of Cmdlets that need to be registered. I will discuss this in details.

Make sure you override the CmdLets property which should return all the Cmdlets that you want to register with PowerShell.
public override Collection Cmdlets

if (null == _cmdlets)
_cmdlets = new Collection();
_cmdlets.Add(new CmdletConfigurationEntry
("Get-Book", typeof(GetBookCommand), "AmazonPS.dll-Help.xml"));
return _cmdlets;

You need to mark the class with RunInstaller attribute

Then you have to install this snapin using installUtil 64 bit utility.
Then the snapin will be registered with the powershell.

Every time you open the powershell console. You have to run Add-PSSnapIn command.

Custom stsadm commnad in SharePoint 2007

The STSADM.EXE utility enables many administrative operations in Windows SharePoint Services that cannot be done with the Central Administration application. See the article Stsadm.exe command-line tool (Office SharePoint Server) in Microsoft TechNet for details. With Windows SharePoint Services 3.0 you can extend the functionality of the STSADM utility by adding your own operations and command line parameters with simple projects using any .NET language.

Creating such a project requires two major tasks.

  1. Create a class that implements the ISPStsadmCommand interface.

  2. Inform STSADM about your extension by registering the class and its assembly.

Create a class that implements ISPStsadmCommand

  1. Start a Class Library project in Visual Studio.

  2. Add using statements for Microsoft.SharePoint and Microsoft.SharePoint.StsAdmin.

  3. Use a namespace that follows the pattern CompanyName.TechnologyName.Feature.SubFeature. For example, AjaxInc.SharePoint.StsAdmin.CustomCommands. (See Names of Namespaces.)

  4. Use a class name that expresses the common denominator of the new STSADM operations that you will be creating; for example, "SortCommands".

  5. The class should inherit ISPStsadmCommand; with a declaration similar to the following.

    public class SortCommands : ISPStsAdminCommand

  6. Write the implementation of the GetHelpMessage method. See the example below.

  7. Write the implementation of the Run method. See the example below.

  8. Compile the project, using the namespace name as the name of the assembly.

  9. Deploy the assembly to the global assembly cache; for example C:\Windows\Assembly.

Register the new class and assembly

  1. Create a text file (UTF-8) named stsadmcommands.uniqueID.xml, where uniqueID is the name of your company or some other ID that ensures uniqueness on any server on which your extension of STSADM might be deployed. The XML declaration should read simply <?xml version="1.0" encoding="utf-8" ?>. The top-level element is <commands></commands>.

  2. For each custom STSADM operation you created—that is, each possible value of the command parameter of GetHelpMessage and Run—add a <command/> element (inside the <commands> element) to your stsadmcommands file with the following syntax. (See the following example.) Change the version and culture values as needed.

            class="fully_qualified_class_name, assembly_name, 
        <!-- other command elements, if any -->

  3. Replace command_name, fully_qualified_class_name, and assembly_name with the appropriate values. (Do not include the ".dll" extension on the assembly name.)

  4. Replace value with the public key token for your assembly which you obtain with these steps.

    1. Right-click your assembly in the global assembly cache and select Properties.

    2. On the General tab, copy the Public Key Token value.

    3. Paste it as the value for PublicKeyToken.

  5. Copy the stsadmcommands.uniqueID.xml file to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG.


The following example shows the *.cs file and, below that, the stsadmcommands.uniqueID.xml file for a custom STSADM operation, called enumfeatures, that will list the features at a site.

using System;
using System.Collections.Specialized;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.StsAdmin;

namespace MS.Samples.SharePoint
    public class SimpleCommandHandler : ISPStsadmCommand
        public string GetHelpMessage(string command)
            return "-url <full url to a site in SharePoint>";

        public int Run(string command, StringDictionary keyValues, out string output)
            command = command.ToLowerInvariant();

            switch (command)
                case "enumfeatures":
                    return this.EnumerateFeatures(keyValues, out output);

                    throw new InvalidOperationException();

        private int EnumerateFeatures(StringDictionary keyValues, out string output)
            if (!keyValues.ContainsKey("url"))
                throw new InvalidOperationException("The url parameter was not specified.");

            String url = keyValues["url"];

            SPFeatureCollection features = null;
            SPWeb web = null;

                SPSite site = new SPSite(url);

                web = site.OpenWeb();

                features = web.Features;
            catch (Exception e)
                throw new InvalidOperationException("Error retrieving url '" + url + "'.  Please check the format of your url, and ensure that the site exists.  Details: " + e.Message);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Features at '" + web.Url + "':\n");

            foreach (SPFeature feature in features)
                sb.AppendLine(feature.Definition.DisplayName + " (" + feature.DefinitionId + ")");
            output = sb.ToString();

            return 0;

Workaround for Double Hop issue

on Friday, November 13, 2009

public class UnImpersonator : IDisposable
        private static extern int RevertToSelf();

        private WindowsIdentity connectedUser = null;

        public UnImpersonator()
            connectedUser = WindowsIdentity.GetCurrent();

        void IDisposable.Dispose()

//Sample Usage 

protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
                using (new UnImpersonator())
                    SqlConnection cn = new SqlConnection("Data Source=servername;Initial Catalog=Employee;Integrated Security=true;");
                    SqlCommand cm = new SqlCommand("select empid,empname from employee", cn);
                    ddlEmployee.DataSource = cm.ExecuteReader();
                    ddlEmployee.DataTextField = "empname";
                    ddlEmployee.DataValueField = "empid";


ListFieldIterator Control to render the sharepoint fields the way you want.

on Monday, November 9, 2009

This control renders each field in a list item with an appropriate control. A single line text field will be rendered as a text box while a lookup field will be rendered as combo box. This control resides in the Microsoft.SharePoint.WebControls namespace of the Microsoft.SharePoint.dll.

In its simplest way you can declare the control as follows:

<spuc:ListFieldIterator ID="TestListFieldIterator" runat="server"
                        ControlMode="Edit" ListId="{e2886b6e-4d63-4063-a02c-eac7fb3aef79}" />

This renders the first list item as follows:


You can also set the ControlMode attribut to Display which renders the list item as follows:


If the control mode is set to New, empty controls are shown.

The way a choice field is rendered depends on the definition of the column. If you opted for a dropdown list when you created the column, the field is rendered as a dropdown. If you opted for check boxes for multi selection, the field is rendered as a list of check boxes:


You can set different properties of the ListFieldIterator control:

  • ListId: This property must contain the id – which is a Guid - of the list you want to display.
  • ControlMode: Defines whether the controls are displayed in display mode, edit mode or new mode.
  • ExcludeFields: Specify the fields that don’t need to be rendered. Separate each field with ;#
  • Item: In code behind, you can retrieve the current list item by using this property.
  • ItemId: in code behind, you can retrieve the id of the current list item. But you can also decide which item to render by setting this attribute declaratively.
<spuc:ListFieldIterator ID="TestListFieldIterator" runat="server"
            ControlMode="Edit" ListId="{e2886b6e-4d63-4063-a02c-eac7fb3aef79}" ItemId="2" />

  • List: In code behind, you can retrieve the current list by using this property.
  • Template: you can set this property if you have deployed your own custom template to the 12\TEMPLATE\CONTROLTEMPLATES folder.

If you first add one or more controls to render fields from the list, and then add a ListFieldIterator control, it will automatically detect the fields already rendered and will not render them anymore. This can be useful if you want to change the order in which the controls must appear, or even more if you want to change the standard rendering of one or more fields (f.e. if you want to render one of the fields using Silverlight :) ).

<spuc:RichTextField ID="ContactTextField" runat="server"  
      ControlMode="Edit" ListId="{e2886b6e-4d63-4063-a02c-eac7fb3aef79}" FieldName="Description"/>

<spuc:ListFieldIterator ID="TestListFieldIterator" runat="server"
      ControlMode="Edit" ListId="{e2886b6e-4d63-4063-a02c-eac7fb3aef79}" />


This does not count for controls added AFTER the ListFieldIterator control.

Don’t forget to add a page directive in order to be able to use the control:

<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls"
             Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

You can use this control in web parts and application pages but in general it is used in custom list definitions. When creating a custom list definition, the columns of the list will be rendered in a standard DisplayForm, NewForm and EditForm. If this standard rendering behavior does not satisfy your needs you can develop your own custom control templates. They need to be deployed in the 12\TEMPLATE\CONTROLTEMPLATES directory and need to be referenced in Forms element of the schema.xml of the custom list definition:

    <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx"  WebPartZoneID="Main"/>
    <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" Template="CustomersForm" WebPartZoneID="Main"/>
    <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" Template="CustomersForm" WebPartZoneID="Main"/>

The Template attribute must contain the name of the template that is defined in an ascx control deployed in the 12\TEMPLATE\CONTROLTEMPLATES folder.

Some Important Links

on Friday, November 6, 2009

Add Custom Actions to UI

Default Custom Action Locations and IDs

Content Types

Hide Multiple Upload menu from a Document Library

on Tuesday, November 3, 2009

Use this javascript

<script language="JavaScript">
function HideNewIcons()
var doc = document.getElementsByTagName('ie:menuitem');
for(var i=0;i<doc.length;i++)

Add Custom Menus using CustomAction

Following are few examples of how to add a new menu to EditControlBlock,SiteSettings Gallary,SiteActions menu.

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="">
    Title="MY ECB ITEM">
    <UrlAction Url="/_layouts/viewlsts.aspx"/>

   Title="MY ECB ITEM">
    <UrlAction Url="/_layouts/viewlsts.aspx"/>

   Title="MY ECB ITEM">
    <UrlAction Url="/_layouts/viewlsts.aspx"/>


Using ControlAssembly to Add New Menus to any GroupId

Check my other blogpost

Hiding Menus in SharePoint


  1. If you want to hide a menu on perticular page then use CEWP(Content Editor WebPart) and put javascript in Source Editor to hide the menu. The id of the menu can be found using ViewSource from the browser. For example to hide siteactions menu from a perticular page use below javascript. Note that to execute any javascript after onload you haveto use _spBodyOnLoadFunctionNames function.

    <script language="JavaScript">
    function HideNewIcons()
    var doc = document.getElementById('siteactiontd');"hidden";

  2. Modify default.master page and put it inside that file.

  3. Use a Feature.

    If you want to control the hiding of the menus by using a Feature so you can turn them on and off at will, and at the farm, application, site collection or site level the you have a little more work to do, but not too much.
    I will return here later and add a full step by step, but here's the code you will need:

    A SharePoint Delegate control:

    Add this to the bottom of your Master Page just before the </body> tag (The ControlId is up to you, but needs to match the Id used in the elements file):
    <SharePoint:DelegateControl runat="server" ControlId="MiscControls" AllowMultipleControls="true"/>

    A .Net User Control: HideMenus.ascx
    <%@ Control Language="C#" ClassName="HideMenus" %>

    <script language="JavaScript">
    var doc = document.getElementsByTagName('ie:menuitem');
    for (var i = 0; i < doc.length; i++){
    itm = doc(i)
    if ('MultipleUpload')!=null'OpenInExplorer')!=null)

    A feature file: Feature.xml
    Title="Hide Menus"
    Description="Sample feature to hide selected menus (MAX Technical Training demo)"
    xmlns=""> <ElementManifests>
    <ElementManifest Location="elements.xml" />

    An elements file: Elements.xml

    <Elements xmlns=""> <Control ControlSrc="~/_controltemplates/HideMenus.ascx" Sequence="100"

SharePoint CustomAction Identifiers

Id GroupId Location Sequence RegistrationType RegistrationId
ReportListActionsMenuCustomizer SiteActions Microsoft.SharePoint.StandardMenu      
Extend WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 10    
Unextend WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 20    
Delete WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 30    
ManagedPaths WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 60    
EmailSettings WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 70    
GeneralSettings WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 80    
ManageContentDatabases WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 90    
ManageWebAppFeatures WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 110    
ListWebApplications WebApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 120    
CreateSite SiteManagement Microsoft.SharePoint.Administration.ApplicationManagement 10    
DeleteSite SiteManagement Microsoft.SharePoint.Administration.ApplicationManagement 20    
SiteUse SiteManagement Microsoft.SharePoint.Administration.ApplicationManagement 40    
QuotaDefinition SiteManagement Microsoft.SharePoint.Administration.ApplicationManagement 50    
SiteQuota SiteManagement Microsoft.SharePoint.Administration.ApplicationManagement 60    
SiteOwners SiteManagement Microsoft.SharePoint.Administration.ApplicationManagement 70    
ListSiteCollections SiteManagement Microsoft.SharePoint.Administration.ApplicationManagement 80    
WebPartSecurity ApplicationSecurity Microsoft.SharePoint.Administration.ApplicationManagement 10    
SelfService ApplicationSecurity Microsoft.SharePoint.Administration.ApplicationManagement 20    
WebApplicationSecurity ApplicationSecurity Microsoft.SharePoint.Administration.ApplicationManagement 30    
ManagePolicy ApplicationSecurity Microsoft.SharePoint.Administration.ApplicationManagement 40    
ManageAuthenticationProviders ApplicationSecurity Microsoft.SharePoint.Administration.ApplicationManagement 50    
OfficialFile ExternalService Microsoft.SharePoint.Administration.ApplicationManagement 20    
HtmlViewer ExternalService Microsoft.SharePoint.Administration.ApplicationManagement 30    
DocConversion ExternalService Microsoft.SharePoint.Administration.ApplicationManagement 40    
WorkflowManagement WorkflowManagement Microsoft.SharePoint.Administration.ApplicationManagement 10    
FarmServers Topology Microsoft.SharePoint.Administration.Operations 10    
TopologyServices Topology Microsoft.SharePoint.Administration.Operations 20    
IncomingEmailServer Topology Microsoft.SharePoint.Administration.Operations 40    
ApproveDGs Topology Microsoft.SharePoint.Administration.Operations 50    
EmailConfiguration Topology Microsoft.SharePoint.Administration.Operations 40    
RunningJobs GlobalConfiguration Microsoft.SharePoint.Administration.Operations 10    
JobDefinitions GlobalConfiguration Microsoft.SharePoint.Administration.Operations 20    
AlternateAccessMappings GlobalConfiguration Microsoft.SharePoint.Administration.Operations 30    
ManageFarmFeatures GlobalConfiguration Microsoft.SharePoint.Administration.Operations 50    
Solutions GlobalConfiguration Microsoft.SharePoint.Administration.Operations 60    
ServiceAccount Security Microsoft.SharePoint.Administration.Operations 10    
Irm Security Microsoft.SharePoint.Administration.Operations 15    
Antivirus Security Microsoft.SharePoint.Administration.Operations 20    
BlockedFileTypes Security Microsoft.SharePoint.Administration.Operations 30    
AdministrationRoles Security Microsoft.SharePoint.Administration.Operations 40    
Backup BackupRestore Microsoft.SharePoint.Administration.Operations 10    
BackupHistory BackupRestore Microsoft.SharePoint.Administration.Operations 20    
Restore BackupRestore Microsoft.SharePoint.Administration.Operations 30    
BackupStatus BackupRestore Microsoft.SharePoint.Administration.Operations 40    
DiagnosticLogging LoggingAndReporting Microsoft.SharePoint.Administration.Operations 10    
UsageAnalysis LoggingAndReporting Microsoft.SharePoint.Administration.Operations 20    
DefaultDatabase DataConfiguration Microsoft.SharePoint.Administration.Operations 10    
DataRetrieval DataConfiguration Microsoft.SharePoint.Administration.Operations 20    
SiteUpgradeStatus Upgrade Microsoft.SharePoint.Administration.Operations 10    
FinalizeUpgrade Upgrade Microsoft.SharePoint.Administration.Operations 20    
CreateSite Links Microsoft.SharePoint.Administration.ApplicationCreated 10    
HomePage Links Microsoft.SharePoint.Administration.ApplicationCreated 20    
ManageAnalytics PortalAnalytics Office.Server.ServiceProvider.Administration 10    
PortalSiteUsage SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 30    
PortalWebUsage SiteAdministration Microsoft.SharePoint.SiteSettings 30    
AddBDCApp BDC Office.Server.ServiceProvider.Administration 101    
BDCApplications BDC Office.Server.ServiceProvider.Administration 102    
BDCEntities BDC Office.Server.ServiceProvider.Administration 103    
MNGPerms BDC Office.Server.ServiceProvider.Administration 104    
BDCProfPage BDC Office.Server.ServiceProvider.Administration 105    
6a9c4822-504f-42fa-b356-817f821f623b ActionsMenu Microsoft.SharePoint.StandardMenu   List 107
ExportEventToolbarButton   DisplayFormToolbar   List 106
ExportContactToolbarButton   DisplayFormToolbar   List 105
ChangeNameDescription General Microsoft.SharePoint.ContentTypeSettings 10    
ChangeOptionalSettings General Microsoft.SharePoint.ContentTypeSettings 20    
ChangeWorkflowSettings General Microsoft.SharePoint.ContentTypeSettings 30    
RemoveContentType General Microsoft.SharePoint.ContentTypeSettings 100    
AddField Fields Microsoft.SharePoint.ContentTypeSettings 10    
ReorderFields Fields Microsoft.SharePoint.ContentTypeSettings 20    
ChangeNameDescriptionGroup General Microsoft.SharePoint.ContentTypeTemplateSettings 10    
ChangeOptionalSettings General Microsoft.SharePoint.ContentTypeTemplateSettings 20    
ChangeWorkflowSettings General Microsoft.SharePoint.ContentTypeTemplateSettings 40    
RemoveContentType General Microsoft.SharePoint.ContentTypeTemplateSettings 100    
AddField Fields Microsoft.SharePoint.ContentTypeTemplateSettings 10    
  Fields Microsoft.SharePoint.ContentTypeTemplateSettings 15    
ReorderFields Fields Microsoft.SharePoint.ContentTypeTemplateSettings 20    
SiteActionsToolbar SiteActions Microsoft.SharePoint.StandardMenu 2001    
DeployManage ContentDeployment Microsoft.SharePoint.Administration.Operations 10    
DeploySettings ContentDeployment Microsoft.SharePoint.Administration.Operations 20    
DeployStatus ContentDeployment Microsoft.SharePoint.Administration.Operations 30    
ChangeDMSettings General Microsoft.SharePoint.ContentTypeSettings 100 ContentType 0x0101
ChangeDMSettings General Microsoft.SharePoint.ContentTypeTemplateSettings 100 ContentType 0x0101
ExcelServerSettings ExcelServer Office.Server.ServiceProvider.Administration 51    
ExcelServerFileTrustedLocations ExcelServer Office.Server.ServiceProvider.Administration 52    
ExcelServerTrustedDcls ExcelServer Office.Server.ServiceProvider.Administration 53    
ExcelServerSafeDataProviders ExcelServer Office.Server.ServiceProvider.Administration 54    
ExcelServerUserDefinedFunctions ExcelServer Office.Server.ServiceProvider.Administration 55    
ewrViewAsHtmlFromForm   DisplayFormToolbar 2500 FileType xlsx
ewrViewAsHtmlFromForm   DisplayFormToolbar 2500 FileType xlsb
ewrViewAsHtmlFromForm   EditFormToolbar 2500 FileType xlsx
ewrViewAsHtmlFromForm   EditFormToolbar 2500 FileType xlsb
ewrViewAsHtmlFromEcb   EditControlBlock 255 FileType xlsx
ewrViewAsHtmlFromEcb   EditControlBlock 255 FileType xlsb
ewrViewSnapshotInExcel   EditControlBlock 256 FileType xlsx
ewrViewSnapshotInExcel   EditControlBlock 256 FileType xlsb
FeaturePushdown Upgrade Microsoft.SharePoint.Administration.Operations 70    
HoldECBItem   EditControlBlock 100 ContentType 0x01
IPFSApplicationConfigurationManage IPFSApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 10    
IPFSApplicationConfigurationConfig IPFSApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 20    
IPFSApplicationConfigurationUpload IPFSApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 30    
IPFSApplicationConfigurationManageDataConnectionFiles IPFSApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 40    
IPFSApplicationConfigurationManageFormsServiceProxy IPFSApplicationConfiguration Microsoft.SharePoint.Administration.ApplicationManagement 50    
FormServerEcbItemOpenXsn   EditControlBlock 255 FileType xsn
FormServerEcbItemOpenInfoPathDocument   EditControlBlock 255 ProgId InfoPath.Document
FormServerEcbItemOpenInfoPathDocument2   EditControlBlock 255 ProgId InfoPath.Document.2
FormServerEcbItemOpenInfoPathDocument3   EditControlBlock 255 ProgId InfoPath.Document.3
FormServerEcbItemOpenInfoPathDocument4   EditControlBlock 255 ProgId InfoPath.Document.4
EnableAudienceTargeting GeneralSettings Microsoft.SharePoint.ListEdit 10    
SiteDirSettings SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 21    
MasterSiteDirectorySettings GlobalConfiguration Microsoft.SharePoint.Administration.Operations 21    
SiteDirectoryLinksCheckerJob GlobalConfiguration Microsoft.SharePoint.Administration.Operations 22    
Migration Upgrade Microsoft.SharePoint.Administration.Operations 50    
AreaNavigationSettings Customization Microsoft.SharePoint.SiteSettings 10    
SearchServiceManagement SearchGroup Microsoft.SharePoint.Administration.ApplicationManagement 10    
configureEnhacedSearch SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 1    
ManageScopes SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 2    
ManageSpecialTerms SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 3    
SearchSettings Search Office.Server.ServiceProvider.Administration 10    
SspSearchAnalytics Search Office.Server.ServiceProvider.Administration 30    
ManageSSP OfficeServerCoreServices Microsoft.SharePoint.Administration.ApplicationManagement 10    
ManageInterFarmServices OfficeServerCoreServices Microsoft.SharePoint.Administration.ApplicationManagement 20    
CheckFarmServices OfficeServerCoreServices Microsoft.SharePoint.Administration.ApplicationManagement 30    
SessionState OfficeServerCoreServices Microsoft.SharePoint.Administration.ApplicationManagement 40    
QuiesceFarm GlobalConfiguration Microsoft.SharePoint.Administration.Operations 50    
LicenseConversion Upgrade Microsoft.SharePoint.Administration.Operations 80    
ChangeCTConverterSettings General Microsoft.SharePoint.ContentTypeTemplateSettings 100    
SchedulingLink GeneralSettings Microsoft.SharePoint.ListEdit.DocumentLibrary 10    
AreaTemplateSettings Customization Microsoft.SharePoint.SiteSettings 10    
CmsMasterPageCatalog Galleries Microsoft.SharePoint.SiteSettings 100    
AreaWelcomePage Customization Microsoft.SharePoint.SiteSettings 10    
AreaCacheSettings SiteAdministration Microsoft.SharePoint.SiteSettings 200    
SiteCacheSettings SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 200    
SiteCacheProfiles SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 200    
ObjectCacheSettings SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 200    
CreatePublishingPage WebPages Microsoft.SharePoint.Create 100    
PublishingSiteActionsMenuCustomizer SiteActions Microsoft.SharePoint.StandardMenu      
AreaChromeSettings Customization Microsoft.SharePoint.SiteSettings 10    
SiteManagement SiteAdministration Microsoft.SharePoint.SiteSettings 210    
NoCrawlSettingsPage Customization Microsoft.SharePoint.SiteSettings 210    
SiteManagerLogs SiteAdministration Microsoft.SharePoint.SiteSettings 250    
VariationSettings SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 210    
VariationLabels SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 220    
VariationLogs SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 230    
TranslatableSettingsPage SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 230    
PolicyTemplate SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 90    
ListPolicySettings Permissions Microsoft.SharePoint.ListEdit 100    
ContentTypePolicySettings General Microsoft.SharePoint.ContentTypeSettings 100    
ContentTypeTemplatePolicySettings General Microsoft.SharePoint.ContentTypeTemplateSettings 100    
AuditSettings SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 70    
PolicyRptConfiguration LoggingAndReporting Microsoft.SharePoint.Administration.Operations 40    
PolicyFeaturesConfig Security Microsoft.SharePoint.Administration.Operations 50    
RelLinksSettings SiteAdministration Microsoft.SharePoint.SiteSettings 100    
AuditReporting SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 71    
WorkflowReporting LeftNavBarLinks Microsoft.SharePoint.Workflows 100    
PeopleAndGroups UsersAndPermissions Microsoft.SharePoint.SiteSettings 10    
SiteCollectionAdministrators UsersAndPermissions Microsoft.SharePoint.SiteSettings 20    
User UsersAndPermissions Microsoft.SharePoint.SiteSettings 40    
ProjectSettings Customization Microsoft.SharePoint.SiteSettings 10    
NavOptions Customization Microsoft.SharePoint.SiteSettings 20    
Theme Customization Microsoft.SharePoint.SiteSettings 30    
TopNav Customization Microsoft.SharePoint.SiteSettings 40    
QuickLaunch Customization Microsoft.SharePoint.SiteSettings 50    
SaveAsTemplate Customization Microsoft.SharePoint.SiteSettings 60    
ReGhost Customization Microsoft.SharePoint.SiteSettings 80    
MasterPageCatalog Galleries Microsoft.SharePoint.SiteSettings 10    
ManageCType Galleries Microsoft.SharePoint.SiteSettings 20    
ManageField Galleries Microsoft.SharePoint.SiteSettings 30    
SiteTemplates Galleries Microsoft.SharePoint.SiteSettings 40    
ListTemplates Galleries Microsoft.SharePoint.SiteSettings 50    
WebParts Galleries Microsoft.SharePoint.SiteSettings 60    
Workflows Galleries Microsoft.SharePoint.SiteSettings 70    
RegionalSettings SiteAdministration Microsoft.SharePoint.SiteSettings 10    
LibrariesAndLists SiteAdministration Microsoft.SharePoint.SiteSettings 20    
WebUsage SiteAdministration Microsoft.SharePoint.SiteSettings 30    
UserAlerts SiteAdministration Microsoft.SharePoint.SiteSettings 40    
RSS SiteAdministration Microsoft.SharePoint.SiteSettings 60    
SrchVis SiteAdministration Microsoft.SharePoint.SiteSettings 65    
ManageSubWebs SiteAdministration Microsoft.SharePoint.SiteSettings 70    
ManageSiteFeatures SiteAdministration Microsoft.SharePoint.SiteSettings 80    
DeleteWeb SiteAdministration Microsoft.SharePoint.SiteSettings 90    
DeletedItems SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 10    
SiteCollectionUsage SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 30    
Storage SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 40    
ManageSiteCollectionFeatures SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 45    
Hierarchy SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 50    
Portal SiteCollectionAdmin Microsoft.SharePoint.SiteSettings 60    
SkuUpgrade Upgrade Microsoft.SharePoint.Administration.Operations 60    
CmsCheckSpellingEditForm   EditFormToolbar 10 ContentType 0x01
CmsCheckSpellingNewForm   NewFormToolbar 10 ContentType 0x01
SingleSignon Security Microsoft.SharePoint.Administration.Operations 50    
ManageProf UAP Office.Server.ServiceProvider.Administration 11    
ManagePriv UAP Office.Server.ServiceProvider.Administration 13    
ManagePS UAP Office.Server.ServiceProvider.Administration 14    
TrustedPersLinks UAP Office.Server.ServiceProvider.Administration 15    
ManagePubLinks UAP Office.Server.ServiceProvider.Administration 16    
ManagePersLinks UAP Office.Server.ServiceProvider.Administration 17    
ManagePermissions UAP Office.Server.ServiceProvider.Administration 18    
ManageAud AUD Office.Server.ServiceProvider.Administration 21    

Adding CustomMenu to any Group in SharePoint using CustomAction & ControlAssembly

Creating Hierarchical Menus with a CustomAction in SharePoint

It’s a fairly known technique to make use of CustomActions to add elements to the out-of-the-box user interface of SharePoint: you can add menu items to the Site Actions menu, you can add links on the Site Settings page, etc. The following piece of XML is the manifest of a feature that will add a new menu item to the Site Actions menu:

<Elements xmlns="">
        Title="Dummy Menu Item"> 

For a more detailed description of CustomActions, I recommend following articles:

Another variation on this technique is to provide a reference to a class, instead of having fixed UI element specified in the XML. The following piece of XML points to the class ListSettingsMenu in the DemoCustomAction assembly.

<Elements xmlns="">

The cool thing is that you now can write code that will render the UI element; it’s even possible to create a hierarchical menu. The following implementation of the ListSettingsMenu class, in combination with the XML from above, is adding one extra menu item to the Site Actions menu (List Settings). This new menu item will contain a sub menu item for every list on the site, these sub menu items will point to the settings pages of the corresponding lists. The ListSettingsMenu class inherits from the WebControl class, by overriding the CreateChildControls method, you can instantiate SubMenuTemplate and MenuItemTemplate instances, and add them to the Controls collection. An instance of the SubMenuItemTemplate class corresponds with a menu item that contains sub menu items. These sub menu items are instances of the MenuItemTemplate class. By setting the Text, Description and ImageUrl properties of these classes, you can specify how the menu items will be rendered in the SharePoint UI. The ClientOnClickNavigateUrl of the MenuItemTemplate class specifies the URL for the menu item itself.

namespace DemoCustomAction
    public class ListSettingsMenu: System.Web.UI.WebControls.WebControl
        protected override void CreateChildControls()
            SubMenuTemplate listSettings = new SubMenuTemplate();
            listSettings.Text = "List Settings";
            listSettings.Description = "Manage settings for lists on this site";
            listSettings.ImageUrl = "/_layouts/images/lg_ICASCX.gif";

            foreach (SPList list in SPContext.Current.Web.Lists)
                if (!list.Hidden)
                    MenuItemTemplate listItem = new MenuItemTemplate();
                    listItem.Text = list.Title;
                    listItem.Description = string.Format(
                        "Manage settings for {0}", list.Title);
                    listItem.ImageUrl = list.ImageUrl;

                    string url = string.Format(
                        SPContext.Current.Web.Url, list.ID.ToString());
                    listItem.ClientOnClickNavigateUrl = url;



To deploy all of this first of all the assembly (DLL) that contains the ListSettingsMenu should be built and copied either to the Global Assembly Cache or the BIN folder of the SharePoint site where you’d like to use it. Secondly the feature should be installed by copying the feature files and running STSADM -o installfeature -n featurename. Finally a SafeControl element must be added to the web.config, so the ListSettingsMenu control is marked as safe. If you forget the last step, you won’t get an error, but the extra menu item won’t be rendered. Here is a screenshot of the result:

The only caveat for this technique seems to be that you can’t use it to add a hierarchical menu in a EditControlBlock (ECB) CustomAction. The menu items of the ECB are rendered using Javascript. If you want to see a full blown example of what you can accomplish, check out the latest addition to the SmartTools project: the Enhanced Site Actions menu.

StepByStep Site Directory in SharePoint

on Sunday, November 1, 2009

Check this link  for step by step instructions for configuring Site Directories.

Choosing between WSS and MOSS

Many clients ask whether they should be using Windows SharePoint Services 3.0 (WSS 3.0) or SharePoint Server 2007. Here is a high level list that I use to help them make this decision.

A high level question to answer is: "Is the organization serious about using SharePoint technologies as part of the tool set that is provided to the end user community." In almost every case where the organization answers "yes" they end up selecting the SP Server 2007 product.

Questions to consider:

  • Is there budget for the project. WSS 3.0 is free, and no CALs are required, while SP Server 2007 costs money per server, typically uses SQL 2005 servers to store the data, and the CALs cost money. So there is a big delta in cost between the two. The Server version of the product can be evaluated before the commitment is made.
  • Are My Sites needed? They're only available in the SP Server 2007.
  • Is a Site Directory needed? The Site Directory feature is only available in the Server 2007 product and can be very helpful if a large number of sites will be created.
  • Are user profiles needed? the Server version of the product can connect to AD and pull in user information which is then stored in the profiles db.> Is there a need to search and index content sources outside of the SharePoint content dbs? If so SP Server 2007 is needed and it can index file shares, web sites, Exchange Public Folders and other sources out of the box.
  • Will the organization be using workflows for production processes? WSS 3.0 is very limited in out of the box workflows, while SP Server 2007 offers more flexibility with Approval, Collect Feedback, Collect Signatures and Disposition Approval workflows.
  • Is integration with MS Information Rights Management (IRM) needed? If so, you need the SP Server 2007 product.
  • Are retention and auditing policies needed? If so, you need the SP Server 2007 product.
  • Will the more advanced branding and publishing tools be needed? SP Server 2007 provides master pages and page layouts that can be used to brand the look and feel of the top-level and subsites.
  • Are policies, auditing and compliance features needed? SP Server 2007 allows for the creation of document retention and expiration policies, workflow processes to define expiration, tacking and auditing and other tools.
  • Are browser-based forms required? If the Enterprise features are enabled with SP Server 2007, browser based forms can be published (so InfoPath is NOT required to fill out a form).
  • Will the organization be using Excel Services? This feature is only available in SP Server 2007.
  • Is the Business Data Catalog required? The Business Data Catalog allows SP to mine data from external databases via application definition files. A number of dedicated web parts then enable SP Server 2007 to display this data to form advanced dashboards.
  • Is Single Sign-On of interest? Again, this is only available with SP Server 2007.