Thursday, April 7, 2011

SharePoint 2010 Windows PowerShell Interview Questions

Q. What is Windows Powershell ?
Ans. Windows PowerShell is a new Windows command-line shell designed especially for system administrators. In the SharePoint administration context, Windows PowerShell is another administration tool that supersedes the existing Stsadm.exe.

Q. How is Windows Powershell different from Stsadm ?
Ans. Unlike stsadm, which accept and return text, Windows PowerShell is built on the Microsoft .NET Framework and accepts and returns .NET Framework objects. In addition to that it also gives you access to the file system on the computer so that you can access registry,digital signature certificate etc..

Q. What are cmdlet's?
Ans. Windows PowerShell introduces the concept of a cmdlet which are simple build in commands, written in a .net language like C# or VB.

Q. Can you Create PowerShell scripts for deploying components in SharePoint ?
Ans. If you are creating a webpart with VS 2010 then you can deploy it using ctrl + f5. However, to activate the webpart feature you can write a powershell script (.ps1) and execute it after dpeloyment.

Q. Where is Powershell located in sharePoint ?
Ans. On the Start menu, click All Programs -> Click Microsoft SharePoint 2010 Products -> Click SharePoint 2010 Management Shell.

Q. If you need going to install a webpart or any custom solution in SharePoint 2010 using PowerShell What permissions do you need?
Ans. In order to use Windows PowerShell for SharePoint 2010 Products, a user must be a member of the SharePoint_Shell_Access role on the configuration and content database. In addition to this, the user must also be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint 2010 Products is installed. See  The Details below

Permissions for Windows PowerShell - SPShellAdmin

In order to use Windows PowerShell for SharePoint 2010 Products, a user must be a member of the SharePoint_Shell_Access role on the configuration and content database. In addition to this, the user must also be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint 2010 Products is installed.

To add a user as SharePoint_Shell_Access on the SharePoint database use the below powershell cmdlet :

Please Note that to run the above cmdlet you must have* Membership in the securityadmin fixed server role on the SQL Server instance
* Membership in the db_owner fixed database role on all affected databases
* and local administrative permission on the local computer.

In addition to above some important things to Note:

* The user gets added to the WSS_Admin_WPG group on all Web servers when the user is added to the SharePoint_Shell_Access role.
* If the target database does not have a SharePoint_Shell_Access role, the role is automatically created.
* If you use the database parameter, the user is added to the role on the farm configuration database, the Central Administration content database, and the specified database. Using the database parameter is the preferred method because most of the administrative operations require access to the Central Administration content database. The cmdlet is something like below :

Add-SPShellAdmin -UserName Domainname\User -database {Database GUID}

Q. How to list all the commands in PowerShell ?
Ans. Get-Command * commands gets you all the Powershell commands. For more commands see
To Open the Windows PowerShell Session :

1. On the Start menu, click All Programs.
2. Click Microsoft SharePoint 2010 Products.
3. Click SharePoint 2010 Management Shell

Note : You should have SharePoint_Shell_Access role on the configuration database and you should be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint Server 2010 is installed.

Some of the Common Commands and Operations are:

Create Web Application Variable
$webapp = Get-SPWebApplication "http://pravahaminfol234/"

Create SharePoint Site Variable (Instance of SPSite)
$siteurl = "http://mysharepointsite/"
$Oursite=new-object Microsoft.SharePoint.SPSite($siteurl)
Here we have created a variable Oursite, which contains an instance of type SPSite. Now you can use it to Display all webs in the site collection.
$Oursite.AllWebs more // List all Webs in the Site

Create Service Application Variable
$spapp = Get-SPServiceApplication -Name "ServiceApplicationDisplayName"

Create a Webapplication:
New -SPWebApplication -ApplicationPoolName <Name of the application pool> -Name <Name of the new Web application> [ -Port <Port on which the Web application can be accessed>] [-HostHeader <Valid URL assigned to the Web application that must correlate to the alternate access mapping configuration>] [-URL <Load-balanced URL for the Web application>][ -ApplicationPoolAccount <User account that this application pool will run as>]

Delete WebApplication
Remove-SPWebApplication –identity -URL <http://sitename/> -Confirm

Create\Delete a Site Collection:
Create a Site collection:
$template = Get-SPWebTemplate "STS#0"
New-SPSite –Url "<URL for the new site collection>" –OwnerAlias "<domain\user>" –Template $template
Here $template is a Variable to store the type of template we want to use while creating a site collection.

Delete a Site Collection:
Remove-SPSite –Identity <URL> –GradualDelete
Here <URL > is a site Collection Url .

Back\Restore a content database
To Backup :
Backup -SPFarm -Directory <Backup folder> -BackupMethod -Item <Content database name> [-Verbose]
Backup folder - is a folder to save your backup.
BackupMethod – Can Specify between Full or Differential.

To Restore:
Restore -SPFarm -Directory <Backup folder> -RestoreMethod Overwrite -Item <Content database name> [-BackupId] [-Verbose]
If you don’t know the BackupID you can display all the backups using the below command and get the GUID of the Backup.
Get-SPBackupHistory -Directory <Backup folder>
You can check all the Backup-Restore Operations Here

Deploy WebPart Soluiton Package
Install -SPWebPartPack -LiteralPath "PathToCABorwspFile" -Name "NameOFWebPart"
PathToCABorwspFile- is the full path to the CAB file that is being deployed.
NameOFWebPart- is the name of the Web Part that is being deployed.

Install Activate and Deactivate Feature using Windows Powershell
Install Feature :
$MyFeatureId = $(Get -SPFeature -limit all where {$_.displayname -eq "myfeatureName"}).Id
Install -SPFeature $MyFeatureId

Activate\Enable Feature :
$singleSiteCollection = Get -SPSite -Identity http://mysinglesitecollectionurl/
Enable -SPFeature $MyFeatureId -Url $singleSiteCollection.URL

Deactivate\Disable Feature :
$singleSiteCollection = Get-SPSite -Identity http://mysinglesitecollectionurl/
Disable -SPFeature $MyFeatureId -Url $singleSiteCollection.URL

Command TO List all the PowerShell Commands
Get-Command –PSSnapin “Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” format-table name > C:\SP2010_PowerShell_Commands.txt

Adding a content database using PowerShell in SharePoint 2010
To attach an existing content database:
Mount-SPContentDatabase "<ContentDb>" –DatabaseServer "<DbServer>" –WebApplication http://webapplicationname/
<ContentDb> is the content database to be attached.
<DbServer> is the name of the database server.
http://webapplicationname/ is the name of the Web application to which the content database is being attached.
To detach a content database:
Dismount-SPContentDatabase "<ContentdBName>"
Where is the name of the content database.

SharePoint 2010 Windows PowerShell Commands - II
Some more PowerShell Commands
Site Collection Commands

Create Site Collection :
$template = Get-SPWebTemplate "STS#0"
New-SPSite -Url "" -OwnerAlias "" -Template $template

Delete Site Collection :
Remove-SPSite -Identity "URL of site Collection" -GradualDelete

Change Site collection Quotas :
Set-SPSite -Identity "SiteCollection Url" -MaxSize Quota

Add site Collection Administrators :
Set-SPSite -Identity "" -SecondaryOwnerAlias ""

Lock or unlock a site collection :
Set-SPSite -Identity "Site Collection Url" -LockState ""
is one of the following vales :
# Unlock: To unlock the site collection and make it available to users.
# NoAdditions: To prevent users from adding new content to the site collection. Updates and deletions are still allowed.
# ReadOnly: To prevent users from adding, updating, or deleting content.
# NoAccess: To prevent access to content completely. Users who attempt to access the site receive an access-denied message.
Create a site :
New-SPSite "http://sitecollection/sites/Subsite -OwnerAlias "DOMAIN\UserName" –Language 1033

More Questions:
More Interview Questions on Sharepoint Programing:
More Interview Questions:Sharepoint 2007/2010 Interview Questions with Answers


  1. Hi

    Tks very much for post:

    I like it and hope that you continue posting.

    Let me show other source that may be good for community.

    Source: Program manager interview questions

    Best rgs

  2. I like the valuable info you provide in your articles.
    I'll bookmark your weblog and check again here regularly. I am quite sure I will learn many new stuff right here! Good luck for the next!

    My homepage password cracker

  3. Greetings! Very useful advice in this particular article!
    It's the little changes that will make the most important changes. Thanks a lot for sharing!

    Here is my page; car town how to make money fast

  4. Do you have a spam problem on this site; I also am a
    blogger, and I was curious about your situation; we have created some nice procedures and we are
    looking to swap solutions with others, why not shoot me an e-mail if interested.

    Check out my site ... twitter password reset

  5. I used to be recommended this blog by way of my cousin. I'm no longer sure whether this publish is written by means of him as no one else recognise such particular approximately my difficulty. You are wonderful! Thanks!

    Visit my page password cracker

  6. I used to be recommended this blog by way of my cousin.
    I'm no longer sure whether this publish is written by means of him as no one else recognise such particular approximately my difficulty. You are wonderful! Thanks!

    my web-site ... password cracker

  7. You're so interesting! I don't believe I have read through
    anything like that before. So nice to find someone with
    some genuine thoughts on this subject. Seriously.. thanks for
    starting this up. This site is something that is needed on the internet, someone with a bit of originality!

    Also visit my web site free psn code

  8. Hello, all is going sound here and ofcourse every one is sharing information, that's truly excellent, keep up writing.

    Also visit my webpage Slim Lipo

  9. I have been surfing online more than three hours today, yet I never found any interesting article like yours.
    It's pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before.

    Here is my web-site - play and get Minecraft for free

  10. Good post. I learn something new and challenging on
    websites I stumbleupon on a daily basis. It will always be
    exciting to read content from other writers and use a little something from their web sites.

    my webpage; get youtube video Views

  11. I've been surfing online more than three hours lately, but I never found any interesting article like yours. It is beautiful price enough for me. In my opinion, if all site owners and bloggers made good content as you probably did, the internet might be a lot more useful than ever before.

    Look at my web site Piezoresistive Microphone

  12. Hi there! This blog post couldn't be written much better! Looking at this post reminds me of my previous roommate! He always kept preaching about this. I most certainly will send this article to him. Fairly certain he will have a very good read. Thanks for sharing!

    Also visit my blog minecraft giftcode

  13. With havin so much content and articles do you ever run into any problems of plagorism or copyright violation?
    My website has a lot of completely unique content I've either created myself or outsourced but it looks like a lot of it is popping it up all over the internet without my agreement. Do you know any solutions to help stop content from being stolen? I'd certainly appreciate it.

    Also visit my blog: Orange County full service catering

  14. It's not my first time to go to see this web page, i am visiting this site dailly and get pleasant information from here every day.

    Have a look at my webpage - looking for castleville friends

  15. Hey there! Do you know if they make any plugins to safeguard against hackers?
    I'm kinda paranoid about losing everything I've worked hard on.
    Any recommendations?

    my web blog sharecash

  16. Pretty nice post. I just stumbled upon your weblog and wished to say that
    I have really enjoyed surfing around your blog posts. In any case I will be subscribing
    to your feed and I hope you write again soon!

    Here is my blog ... how can i get paid to travel

  17. I like the helpful info you supply on your articles. I will bookmark
    your weblog and check once more here frequently. I am fairly certain I'll learn a lot of new stuff right here! Best of luck for the next!

    Feel free to visit my weblog Funny Cartoons

  18. Can I simply say what a comfort to find somebody who actually understands what they're discussing on the net. You definitely understand how to bring an issue to light and make it important. More and more people ought to read this and understand this side of the story. I can't
    believe you're not more popular given that you most certainly possess the gift.

    My web site :: federal credit

  19. Your means of telling everything in this post is
    really fastidious, every one can effortlessly be aware of it, Thanks a lot.

    Also visit my web-site Aimbot and Wallhack

  20. Very rapidly this web site will be famous among all blogging and site-building users, due to
    it's nice articles

    Check out my web site ... reputation management for individuals

  21. Greetings, I think your web site might be having internet browser compatibility problems.
    Whenever I take a look at your site in Safari,
    it looks fine but when opening in IE, it's got some overlapping issues. I merely wanted to give you a quick heads up! Aside from that, excellent site!

    Also visit my web site ... dragonvale tool hack

  22. I've learn some good stuff here. Certainly price bookmarking for revisiting. I surprise how so much attempt you set to make any such excellent informative website.

    Feel free to surf to my homepage international private medical insurance

  23. I always spent my half an hour to read this web site's posts daily along with a cup of coffee.

    Here is my website: Free Minecraft

  24. Very quickly this website will be famous amid
    all blogging and site-building users, due to it's fastidious articles or reviews

    my web blog Get minecraft for Free

  25. of course like your website but you need to test the spelling on several of your posts.

    Many of them are rife with spelling problems and I find it very
    troublesome to inform the reality on the other hand I will surely come again

    my page; hack a twitter

  26. Hello, i think that i saw you visited my web site so i came to “return the favor”.
    I'm attempting to find things to enhance my site!I suppose its ok to use some of your ideas!!

    My page: sharcash bypass

  27. Howdy! I could have sworn I've been to this site before but after looking at a few of the articles I realized it's new to me.
    Regardless, I'm definitely happy I came across it and I'll be
    book-marking it and checking back frequently!

    Here is my blog post: pwd recovery

  28. Cross the legs once again and bring up your organism losing exercising weight overfree weight, but the ultimate one is how you sense about yourself.
    Eat piles... 10 large calories for punt of one's weight. People who are overweight may find untempting or small-scale home base for a unproblematic way to shuffle you find fuller. You may likewise use the acai berry juice as possibly is likewise a must, so that you get word to do this sort of intricate mannerism, the correct way. You'll be faring this ago God Apollo was
    a symbol of strong-arm military capability and manhood.

    my web site - truth about abs reviews & ordering

  29. And, remember that the harder and larger is no transposition for a penis enlarging.

    Suffices Global if you had a manlike sex
    organ that is bigger than the mean? By performing sealed penis physical exertions, you can excite the rakehell stream that flowings into the do is livelihood
    yourself informed and do some inquiry on the mathematical product.
    Only gazing at a buster's penis enlarging does a great deal in posing a penis enlarging truly operate?

    Here is my site; great post to read []

  30. In case you are looking into making cash from your traffic by running popunder ads - you should try one of the biggest companies - PopCash.