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

  • 相关阅读:
    Linux crontab 的常用定时方式
    Windows 查看端口及进程信息
    java.io.IOException: com.esotericsoftware.kryo.KryoException
    Linux 如何让挂载的硬盘永久生效
    六边形架构-微服务基石
    包和工具
    谈一谈对java简单的理解
    HTTP报文 「HTTP
    四层 or 七层 「HTTP
    setTimeout不生效
  • 原文地址:https://www.cnblogs.com/frankzye/p/1834614.html
Copyright © 2011-2022 走看看