.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

powershell command New-SPSite does not activate featues

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :SharePoint

I am using the powershell command New-SPSite to create a new instance of a custom site definition in SharePoint 2010.  Unfortunately it creates an empty site and none of the featues defined in the onet.xml of the custom site definition seem to get activated.  When I create this same site definition through the UI it works fine (features in the onet.xml do get activated).  Given below is the set of commands I use

$template = Get-SPWebTemplate "Custom#0"

New-SPSite -Url $SiteUrl –OwnerAlias domain\account –Template $template

Does anyone have any idea as to what is going wrong?


View Complete Post

More Related Resource Links

Is there PowerShell command to change service application account?


I associated User Profile Synchronization Service with managed account "svcebrd" in CA. For some reason this created duplicated managed account. Now there are two "svcebrd" under Configure Managed Account. If I try do delete one of the accounts in CA I get "key has already been added in dictionary". Running Remove-SPManagedAccount fails with "The account Dev\svcebrd is still being used by ... User Profile Syncronization Service".

Does anybody know powershell command to changed service application account?


Row command working on all rows not selected one?



I have this code that hides a column in a gridview.  (The column houses another nested gridview).

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "Select" Then
            If GridView1.Columns(0).Visible = False Then
                GridView1.Columns(0).Visible = True
                GridView1.Columns(0).Visible = False
            End If
        End If
    End Sub

The trouble is that if I click the select link on one row that action to hide is carried out on all rows.  How can I set this up so that it only hides the row that is selected?


Print command



Is there a way of setting up a print area for a part of my webpage, I only want to print a certain part of the page, when I select print at the moment it will print the whole page and the layout is rubbish!!

command object error


Could someone please tell me what is wrong with my syntax here?  I'd be much appreciative.


objCmd = New SQLCommand("SELECT CASE WHEN objDR('Item') = 'Enter Bill of Lading' then enterbol " _  

& "WHEN objDR('Item') = 'Bill of Lading History' THEN bolhistory " _  

& "WHEN objDR('Item') = 'Request Transfer' or objDR('Item') = 'View Transfer in Progress' THEN transfers " _  

& "END  from plantGroups where plantgroupid=@plantgroupid", objConn)

Test Run: Request/Response Testing with Windows PowerShell


Did you know you can use Windows PowerShell to perform lightweight request/response testing for an ASP.NET Web app? Here's how.

Dr. James McCaffrey

MSDN Magazine May 2008

Test Run: Web UI Automation with Windows PowerShell


Here we show you how to use Windows PowerShell to create quick and easy UI test automation for ASP.NET and classic ASP Web applications.

Dr. James McCaffrey

MSDN Magazine March 2008

Cmdlets: Extend Windows PowerShell With Custom Commands


Jim Truher presents an introduction to writing and registering your own custom cmdlets to be used in Windows PowerShell.

Jim Truher

MSDN Magazine December 2007

Test Run: UI Automation with Windows PowerShell


This installment of Test Run is a guide to using Windows PowerShell to perform ultra lightweight UI automation.

Dr. James McCaffrey

MSDN Magazine December 2007

Design Patterns: Simplify Distributed System Design Using the Command Pattern, MSMQ, and .NET


Service-oriented architecture is a great framework when you need to perform distributed computing tasks over the Internet. But when you want to perform processing inside your local network, a different solution may provide a better fit. That solution, based on the Command pattern, uses Windows services and Microsoft Message Queuing to implement a queued system that meets your needs better than a service-oriented solution. This article explains how to build it.

Brad King

MSDN Magazine September 2004

Command Management: Use Design Patterns to Simplify the Relationship Between Menus and Form Elements


In Windows Forms applications, similar commands, such as those in a menu and their counterparts on a toolbar, are not automatically related. They don't fire the same event or run the same handler routine. Yet code that allows the same or similar user commands to fire the same code simplifies development.This article describes the principles of command management and why it's important to have functional commands that are not exclusive to any one UI element. In order to provide an MFC-like command management infrastructure, a design pattern is developed and applied as a series of C# classes.

Michael Foster and Gilberto Araya

MSDN Magazine October 2002

Error connecting using SPSite

Has anyone seen this error message?

The Web application at http://ecnet/Pages/Default.aspx could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

Errors on the line.

SPSite site = new SPSite("http://ecnet/Pages/Default.aspx");

It's a clean console application running on the SharePoint 2007 web server.

Any thoughts? I can't seem to connect to the Server like I used to in SharePoint 2003.

Why feature with event receiver doesn't activate properly after site provisioning?



I have defined feature with event receivers for my document library and for users List .

I try to activate my feature in onet.xml in section <WebFeatures>. After provisioning a new site from onet.xml  all work fine and my feature is shown as activated, but event receivers doesn't fire. It fires only after reactivating my feature (deactivate, then activate it again). But I need my feature works immediately after site provisioning without deactivating and activating it again. Who knows how to solve this problem?

part of ONET.xml



        <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"/>

        <!-- TeamCollab Feature -->

        <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"/>

        <!-- MobilityRedirect -->

        <!--My EventReceivers Feature-->

        <Feature ID ="41178843-A6A4-47c7-9EF9-B8A432E02B88"></Feature>





stsadm Import command + include user security



When I move sites from test to staging to production, I am using the stsadm –o export command with the –includeusersecurity option in the staging environment.  In production environment, I then use the stsadm –o import command with the –includeusersecurity option.  I was assuming that this option was bringing over the security on the exported site only.  This does not seem to be the case.

Last night I exported one sub site to produtction.  Today, I was notified that the security groups on other sub sites have been altered.  


So why is it when using the –includeusersecurity option effect all sub sites and not just the one sub site being moved from staging to production

Executing Command Logic in a View Model

Through the use of the Windows Presentation Foundation's (WPF) advanced data-binding capabilities, the logical structure of a user interface can relatively easily be disconnected from its presentation. Bindable components can now contain nearly all of an application's user interface logic and in most circumstances, replace the need for controller objects from the classic Model-View-Controller (MVC) pattern. So it's no wonder that a new pattern for UI design has appeared

Video: SharePoint 2010 Integration with PowerShell

Learn about the new PowerShell integration in SharePoint 2010, which brings SharePoint administration in line with other server products such as Exchange. Understanding PowerShell is a must-have skill for SharePoint 2010 developers. (Length: 19:52)

Trying to get SPSite when called through a web service


I have built a custom timer job that makes calls to a web service that I built.  The reason I built the web service is because I recognized that the sharepoint timer job does not have context for a site and I thought that by having the timer job call the web methods of the web service I could have the context that I desire.  This works great for accessing the web.config file, however, I have discovered that I am unable to get SPSite (SPSite oSite = new SPSite(AbsoluteURL)).  The constructor does not throw an error but I am unable to use the new object.  If I am able to get to the web.config and the site is a SharePoint site I figure I should be able to get an SPSite object.

I am trying to understand if I am running into a known scenario or if this should work and that I have a bug that I don't recognize.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend