List of SharePoint 2010 Management Shell Commands

As I have been having trouble with manually adding my finished SharePoint project to a different web application, I have had to turn to using Powershell to get my project deployed from one web application to the next.

My reasons for writing this is because sometimes when I Google for this, I can never find someone that gets straight to the point or include a walk-through or explanation! That could just be me not looking hard enough, however I am writing a list here so I can use for reference and hopefully help someone that is stumbling along looking for the same lists as I were. 🙂

  1. First of all, you are going to want to open up ‘SharePoint 2010 Management Shell‘. To find this, click your ‘Start’ menu and ‘All Programs’. It will be found under ‘Microsoft SharePoint 2010 Products’.

    Please make sure that you run it as administrator! You can do this by right-clicking the Powershell and pressing ‘run as administrator’.

  2. When you have clicked this, it should look something like this –

    For those that cannot read this, it says “PS C:Usersk.b >” Although I have blanked out almost all of my name apart from my initials, this is where your user log in will appear.

  3. However, the first time I attempted to do this I was faced with an error. The error says ‘The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered‘.

    If you do receive this error, talk to your networking administrator. However, if do the networking side of SharePoint as well, I found that this link on SharePoint Assist and think it will help out.

  4. Make sure that you have copied over your .wsp file of your SharePoint project over to the desired web application. Make sure it is saved in an accessible folder and somewhere where you will remember it.
  5. First, you are going to need to add your solution.

    To add, you need to write:
    Add-SPSolution -LiteralPath The location of your .wsp file. Just a note, Windows Powershell does not like spaces in your path name so if you have a folder such as ‘Visual Studio 2010’ or anything with spaces, please try and rename your folder(s)!

    This makes mine read:
    Add-SPSolution -LiteralPath C:Usersk.bDocumentsExpenses_Form.wsp When you press enter, you will given the name of your .wsp file, a ‘SolutionId‘ and Deployed = False. Do not panic that deployed is false at this stage – this is what we want!

  6. Next you’re going to want to deploy the solution to your web application.

    To do this, you will need to type: Install-SPSolution -Identity your wsp file.wsp -WebApplication http://yourwebapp -GACDeployment

    Therefore for my example it will be:
    Install-SPSolution -Identity Expenses_Form.wsp -WebApplication http://hc-sps-dev2 -GACDeployment If you get an error message saying “This solution contains no resources scoped for a Web application“, please view my blog post, Ensuring your SharePoint project is classed as a ‘web application’, as I came across this problem myself.

  7. To check this has been done, go into your SharePoint 2010 Central Administration. Go into System Settings and then under the Farm Management header, click ‘Manage Farm Solutions‘. Click your new solution file and click ‘Deploy’ along the top.
  8. PLEASE MAKE SURE THAT YOUR SHAREPOINT PROJECT HAS A FEATURE. If you deleted this, you will have to remake it again, because without it you are not going to be able to find the solution to activate it in your web application. If this has happened you are going to have to remove the .wsp file and redeploy it at a later date.
  9. To remove a .wsp solution file, make sure you remove it from Central Administration first. Then open up your Powershell.

    To remove the solution, you type:
    Remove-SPSolution -Identity .wsp file name

    So, in context of my example:
    Remove-SPSolution -Identity Expenses_Form.wsp

    Once you have pressed enter, you will be prompted with whether or not you confirm that you want to delete it. ‘Y’ (which means yes) is the default, otherwise there are a few more options you can press. Typing ‘Y’ will delete your solution!

  10. Other commands to mention are “Update” and “Uninstall“.

    Update

    Update-SPSolution -Identity .wsp file name -LiteralPath “Name of web application” -GACDeployment

    So in terms of my example it would be:
    Update-SPSolution -Identity Expenses_Form.wsp -LiteralPath http://hc-sps-dev1 -GACDeployment

    Uninstall

    Uninstall-SPSolution -Identity .wsp file name -WebApplication name of web application

    Lastly, in context of my example:
    Uninstall-SPSolution -Identity Expenses_Form.wsp -WebApplication http://hc-sps-dev2

I hope this helps you as reference material or even if you are new to using Powershell! Please leave a comment if you are stuck or something is unclear!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s