zoukankan      html  css  js  c++  java
  • Adding and Deploying Solutions with PowerShell in SharePoint 2010

    Visual Studio 2010 makes it really easy to add and deploy solutions when you are developing, but you may eventually want to deploy those solution packages elsewhere right?  We can still use stsadm, but that is effectively considered deprecated now in favor of PowerShell.  In the past to add a solution, we used an stsadm command like the one below.  In today’s example, we’ll be working with a package called SharePointProject2.wsp on my server named sp2010.

    stsadm –o addsolution –name SharePointProject2.wsp

    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 snappin so that we can execute SharePoint commands.  To install a solution we use the Add-SPSolution command.  If you are using a Sandboxed solution you would use Add-SPUserSolution instead.  It takes just one parameter, –literalpath, which is the path to the solution file.  One thing that is different is that you must specify the full path to the file for some reason.  I haven’t been able to get it to take a path to the solution in the current folder even if I make use of .\ before the filename.  Here is an example.

    Add-SPSolution c:\code\SharePointProject2\bin\debug\SharePointProject2.wsp

    In this case you don’t actually have to type –literalpath before the parameter.  This is what it looks like when executed.  You can see that it displays the id of the solution along with its deployment status.

    PowerShellAddSolution

    Now we need to deploy the solution.  In the past, we used an stsadm command like the following.

    stsadm –o deploysolution –name SharePointProject2.wsp –url http://moss-server –allowCasPolicies –immediate

    We would also follow this up with a call to stsadm with the execadmsvcjobs operation.  To do the same operation in PowerShell, we use the Install-SPSolution command (again use Install-SPUserSolution for Sandboxed solutions).  You can use the Get-Help command (i.e.: Get-Help Install-SPSolution) to get more information on a command but it’s not always obvious what it is expecting as you can see below.  That is why I am writing the post today.

    PowerShellGetHelpInstallSolution

    The first parameter you need is the –Identity parameter.  This is the name of the solution package (i.e.: MySolution.wsp).  Depending on if you are using the GAC or Code Access Security, you will specify either –GACDeployment or –CASPolicies.  You then need to specify a specific web application using the –WebApplication parameter or –AllWebApplications to deploy it to all web applications (assuming the manifest allows it).  If you need to force the deployment, you can still use the –Force command.  Here is what an install command might look like.

    Install-SPSolution –Identity SharePointProject2.wsp –WebApplication http://sp2010 -GACDeployment

  • 相关阅读:
    低调 、隐忍、善良应是最应该修炼的
    达内C++培训课程
    这三天低效率开发的总结,我都做了些什么啊?
    linux sysfs(1)
    编码问题
    Linux中的system函数的实现和解释
    北京邮电大学 程序设计课程设计 电梯 文件输入版本(已调试,大致正确运行==)
    "Dallas" CTP3 发布通告
    结合使用PowerPivot 和 "Dallas" CTP3
    Windows Azure 解决方案系列: 能源监测减少支出,通过托管平台拓展业务
  • 原文地址:https://www.cnblogs.com/frankzye/p/1834614.html
Copyright © 2011-2022 走看看