Search This Blog

Tuesday, June 21, 2011

How to Activating and Deactivating Features with PowerShell in SharePoint 2010

I was looking at the analytics of the site the other day and I noticed that my post, Adding and Deploying Solutions with PowerShell, currently has the most traffic on the site.  I had always intended to write a follow up post on this, so here it is.  Today I’m going to talk about how to enable and disable features using PowerShell.  It’s great that you know how to deploy solutions now with PowerShell, but now you want to activate your features.
In SharePoint 2007 to activate a feature from the command line you might have used a statement like the one below.  I’ll use the Reporting feature on my server named sp2010 as an example.  The value specified in the name parameter refers to the actual folder name of the feature that is in your SharePoint Root folder (14 hive).

stsadm.exe –o activatefeature –name Reportingurl http://sp2010

To get started with PowerShell, run the SharePoint 2010 Management Console located in your Microsoft SharePoint 2010 Products folder on your start menu.  This automatically loads the Microsoft.SharePoint.PowerShell snapin so that we can execute SharePoint commands.    You might have noticed earlier that I said we will talk about enabling and disabling features.  The words enable and disable are key here because PowerShell uses those verbs to activate and deactivate features.  To issue the same command above but with PowerShell, we use the Enable-SPFeature command.  The rest of the syntax is pretty similar as you can see below.  Just use Identity to specify the name of the feature.  You can even pass the –Force command like you could with stsadm.exe.

Enable-SPFeature –Identity Reporting –url http://sp2010

If your command worked successfully, you will see nothing and just get a blank prompt back.


If you would like to get some feedback from the command, you can have it return the SPFeature object back to you by specifying thePassThru parameter.



We can confirm that the feature did in fact activate successfully using the SharePoint UI.



Can we confirm that the feature is enabled with PowerShell?  Yes, we can by using Get-SPFeature.  Now this cmdlet behaves differently depending upon the parameters passed through it.  For example, if you type the following, it lists every feature on the SharePoint farm along with its Id and Scope.

Get-SPFeature

However, if you want to know which features are enabled, you can pass it a URL for a given scope (i.e.: –Web, –Site, –WebApplication, and –Farm).  So to get a list of all Site Collection scoped features, we would use the –Site parameter.

Get-SPFeature –Site http://sp2010


You can still specify a specific feature or even use Where-Object to query the list as well.

Get-SPFeature –Identity Reporting –Site http://sp2010


If you get something like you see in the screenshot above, you know the feature has been activated.  When the feature hasn’t been activated, you will get a lovely red error message.




The Enable-SPFeature command can also take a Pipe Bind from Get-SPFeature.  This means that you could even activate multiple features at once this way.  I’ll include an example of this in the future.
At some point, you will want to disable that feature you activated.  As you probably guessed, the cmdlet you want is Disable-SPFeature.  You use the same parameters that you use with Enable-SPFeature.  When you execute the command, it prompts for confirmation as you can see in the screenshot.

Disable-SPFeature –Identity Reporting –url http://sp2010




If you want to disable confirmation, you can pass the –confirm:$false parameter.

Disable-SPFeature –Identity Reporting –url http://sp2010 –Confirm:$false





Setting the confirm parameter eliminates the confirmation prompt and you can use it with other PowerShell cmdlets as well.  That is all that is involved in activating and deactivating features with PowerShell.  It’s pretty easy.   Hopefully, you can incorporate these commands in your deployment scripts.

34 comments:

  1. My spouse and I stumbled over here by a different web page
    and thought I might check things out. I like what I see so i
    am just following you. Look forward to looking over your
    web page repeatedly.
    See this: zobacz,
    http://prince-of-persia.pl

    ReplyDelete
  2. This is a good tip particularly to those new to
    the blogosphere. Short but very precise information… Thank you
    for sharing this one. A must read post! odwiedĹş stronÄ™, http:
    //abusada.net/blog/?page_id=79
    Also see my page :: odwiedĹş stronÄ™

    ReplyDelete
  3. My brother suggested I might like this web site. He was entirely right.
    This post actually made my day. You can not imagine just how much time I had spent for this information!
    Thanks!
    See this: e-horoskopdzienny.pl,
    http://horoskop.Wordpressy.pl/

    ReplyDelete
  4. Why viewers still use to read news papers when in this technological globe all is accessible on web?

    See this: zobacz, http://sim-city.
    com.pl

    ReplyDelete
  5. Its like you read my mind! You appear to know a lot about this, like you wrote the book in it
    or something. I think that you can do with some pics to drive the message home
    a little bit, but other than that, this is wonderful blog.
    An excellent read. I will certainly be back. zobacz, http://www.
    halvezolenlijntje.nl/?page_id=265

    ReplyDelete
  6. Hello colleagues, how is everything, and what you want to
    say on the topic of this article, in my view its really amazing
    in favor of me. więcej - link, http://chillwithfriends.
    com/index.php?do=/blog/97523/karty-tarot-wróżby/

    ReplyDelete
  7. I am really inspired together with your writing abilities
    as well as with the layout for your weblog. Is this
    a paid topic or did you modify it yourself? Anyway keep up the nice
    high quality writing, it's uncommon to peer a great weblog like this one these days..
    See this: zobacz, http://abased.warszawa.pl

    ReplyDelete
  8. I am really inspired together with your writing abilities as well
    as with the layout for your weblog. Is this a paid topic or did you modify it yourself?
    Anyway keep up the nice high quality writing, it's uncommon to peer a great weblog like this one these days..
    See this: zobacz, http://abased.warszawa.pl
    Also see my site: zobacz

    ReplyDelete
  9. Write more, thats all I have to say. Literally, it seems
    as though you relied on the video to make your point.
    You clearly know what youre talking about, why waste your intelligence on just posting videos to your
    site when you could be giving us something enlightening to read?

    See this: zobacz,
    http://ablaze.waw.pl
    My webpage: zobacz

    ReplyDelete
  10. Spot on with this write-up, I honestly feel this site needs far more attention.

    I'll probably be back again to read more, thanks for the info!
    See this: zobacz, http://abilities.katowice.pl

    ReplyDelete
  11. The other day, while I was at work, my sister stole my apple ipad and tested to see if
    it can survive a 30 foot drop, just so she can be a youtube sensation.

    My iPad is now broken and she has 83 views. I know this is completely off topic but I had to share it with someone!

    link,
    http://s-hue.co.kr/?mid=article&document_srl=4336
    My site :: link

    ReplyDelete
  12. I have been browsing online greater than
    3 hours today, yet I by no means found any attention-grabbing article like yours.
    It's pretty worth enough for me. Personally, if all site owners and bloggers made just right content material as you did, the web will probably be much more useful than ever before.
    See this: http://driver24.com.pl, http://torchlight24.pl

    ReplyDelete
  13. Good day! I could have sworn I've been to this website before but after checking through some of the post I realized it's new to me.
    Anyhow, I'm definitely delighted I found it and I'll be bookmarking and checking back often!
    zobacz, http:
    //vjchurch.net/xe/?mid=Top05&sort_index=voted_count&order_type=desc&listStyle=webzine&document_srl=381
    Also see my website :: zobacz

    ReplyDelete
  14. Hey! I know this is somewhat off topic but I was wondering which blog platform are you using for this site?
    I'm getting fed up of Wordpress because I've had issues with hackers
    and I'm looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.
    See this: horoskop lew, http://wrozby-24.pl

    ReplyDelete
  15. Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to more added agreeable from you! By the
    way, how can we communicate? zobacz, http://tiarbi.
    com/punbb/profile.php?id=500

    ReplyDelete
  16. As the admin of this website is working, no hesitation very shortly it will be famous, due to its feature contents.
    ciekawy blog, http://www.

    doctorslounge.com/index.php/member/57535

    ReplyDelete
  17. Thanks in support of sharing such a pleasant opinion,
    piece of writing is fastidious, thats why i have read it entirely
    See this: waw.pl, http://abhors.
    katowice.pl/?p=36

    ReplyDelete
  18. It's amazing to pay a quick visit this web site and reading the views of all mates concerning this post, while I am also keen of getting knowledge.

    Here is my web-site ... raspberry ketone

    ReplyDelete
  19. A new Peek In your own home Vu Projector's Brand new Tm091 Pico Projector: The Smartest Yet

    Feel free to surf to my weblog - Epson Powerlite Home Cinema 3010 - www.10projectors.com

    ReplyDelete
  20. Its appearance is note-bookish and minimalistic having no front button.
    I can hook up to the internet several ways - with the wireless ability it's, or tethering for you to my cellphone or, if you've got
    a Blackberry working version 5 as well as above you should use the Fill to access the net while about.

    Sources demonstrate that this newly designed solution designed to offer a streamlined framework for enterprises to unfurl mobile
    apps for Blackberry Play - Book tablet users within the
    organization.

    my web-site blackberry playbook

    ReplyDelete
  21. First off I want to say terrific blog! I had a quick question in which I'd like to ask if you don't mind.
    I was interested to know how you center yourself and
    clear your mind before writing. I've had a difficult time clearing my mind in getting my ideas out. I do enjoy writing but it just seems like the first 10 to 15 minutes tend to be wasted simply just trying to figure out how to begin. Any ideas or hints? Cheers!

    Feel free to surf to my web blog Solde Air Jordan

    ReplyDelete
  22. Hi, I do believe your blog could possibly be having internet browser compatibility problems.
    Whenever I take a look at your site in Safari, it looks fine however,
    when opening in Internet Explorer, it has some overlapping issues.

    I just wanted to give you a quick heads up! Apart from that, great website!


    http://agrmertola.drealentejo.pt/user/view.php?id=61517&course=1
    http://allbecauseheasked.com/brief-strategies-how-buy-real-followers-twitter
    http://africanamericansupersite.com/index.php?do=/blog/115172/buy-authentic-followers-of-the-twitter/
    http://africanamericansupersite.com/index.php?do=/blog/162031/twitter-followers-for-the-basics/
    http://alumni.cahcet.com/IvanMilli/tab:info

    Here is my website: lohonline

    ReplyDelete
  23. Awesome! Its in fact awesome piece of writing, I have got much clear idea about from this piece of writing.



    Here is my homepage home income

    ReplyDelete
  24. Hi, I think your website may be having internet browser compatibility issues.
    When I take a look at your blog in Safari, it looks
    fine however, when opening in I.E., it has some overlapping issues.
    I merely wanted to provide you with a quick heads up! Other than that, great blog!


    Feel free to visit my website :: calories burned walking

    ReplyDelete
  25. Tenants and non-collateral holders are able to fill up the high possibleness of extended interestingness tax.
    If so, with diminutive concern loans you can range the goal hap to be make in unlocked characteristic which may be imply, group do not to subsidization any
    limited covering straightened mistreatment the home loan.
    The best dimension of this programme is that it offers hold
    for door-to-door online dealing. In add-on fast loans, constituentally you can have have to pay some constituental fees as late settlement, but this should be done in beforehand
    and not on the spot of the due date. If you earn per time unit
    1000 from your without participation of recognition proof cognitive mental operation.
    So, if you are in need of business that is worthy availing in a very fast
    comes in betwixt 100 to 1500, depending upon your inevitably and
    payment capability. payday loansThere are so many kinds it can be car could be kept as legal document.

    You should draft out unequaled websites and find most typically finances to carry off their unexpected financial inevitably even they got
    time unit wage.

    ReplyDelete
  26. Whats up! You some sort of expert? Great message. Are you able to tell
    me how you can subscribe your blog?

    Feel free to visit my blog: having trouble getting pregnant with second baby

    ReplyDelete
  27. Write more, thats all I have to say. Literally, it
    seems as though you relied on the video to make your point.
    You obviously know what youre talking about, why throw away your intelligence
    on just posting videos to your blog when you could be
    giving us something enlightening to read?

    Here is my site - pharmacy technician program

    ReplyDelete
  28. In general, consolidate debt loans are usually an effective
    means to fix financial loan problems. It is still important to be aware that they may deduct their payoff terms directly upon your receiving your next paycheck.

    According to the statistics, an average American citizen pays 11 different creditors, which
    can help you to enjoy more disposable income each month.
    You have both two options of secured and unsecured through No credit check students consolidation
    loans. There are specific advantages to consolidating debts and
    clearing them in one go.

    ReplyDelete
  29. The prices and the knowledge of the sales staff can vary from low end to high end.

    Whenever you try to call your how to get a girlfriend
    your choice of deodorant or aftershave lotion you want now?
    You embark on a Friday or Saturday night just does not
    do an evaluation in her mind when you engage all five of her senses in your marketing
    scheme. However, you can either get the how to get a girlfriend pillow.
    Before I tell you some of these products to check out
    whether they really work?

    Here is my web blog :: web page

    ReplyDelete
  30. Hi, I do believe this is a great web site.
    I stumbledupon it ;) I will return once again since i have saved as a favorite it.
    Money and freedom is the greatest way to change, may you be rich
    and continue to help others.

    Feel free to visit my web site :: Louis Vuitton Outlet

    ReplyDelete
  31. Any 9th New release Lancer

    Also visit my homepage; paday loans uk

    ReplyDelete
  32. Hello There. I found your blog using msn. This is a very
    well written article. I will be sure to bookmark it and come
    back to read more of your useful info. Thanks for the post.
    I'll definitely comeback.

    Here is my blog; NFL wholesale Jerseys

    ReplyDelete
  33. Hey There. I found your blog using msn. This is a really well
    written article. I will be sure to bookmark it and return to read more of your useful info.
    Thanks for the post. I will certainly return.

    My blog ... Sac A Main Louis Vuitton

    ReplyDelete
  34. Nice blog. You have created a very nice blog to share information about SharePoint which I find really helpful for newbies like me. I will frequently visit your blog. Keep posting.
    electronic signature for sharepoint

    ReplyDelete