SharePoint PowerShell在SharePoint Product列表里边,然后以管理员权限启动。

1. 添加Solution 到 SharePoint Farm.

Add-SPSolution  D:\Sp2010\DeploySolution\MySharepointProject.wsp  (farm)
Add-SPUserSolution -LiteralPath "c:\ilt.wsp" (sandbox)

2.获取已添加到SharePoint Farm的Solutions.

Get-SPSolution

3. 部署Solution 到SharePoint。

部署Solution到SharePoint Farm中:

Install-SPSolution –Identity MySharepointProject.wsp –WebApplication http://myserver-sp1:2010/  -GACDeployment
Install-SPSolution -Identity ilt.wsp -GACDeployment
 
 如果部署的是 Sandboxed solution,则使用Install-SPUserSolution命令。

    –GACDeployment 参数也可换成–CASPolicies,二者区别是
          GACDeployment指定可以为新 SharePoint 解决方案部署全局程序集缓存 (GAC)。。
           CASPolicies指定可以为新 SharePoint 解决方案部署代码访问安全 (CAS) 策略。
     - WebApplication参数也可换成- AllWebApplications,二者区别是:
         WebApplication: 为指定 SharePoint Web 应用程序部署 SharePoint 解决方案。该类型必须是格式为 12345678-90ab-cdef-1234-567890bcdefgh 的有效 GUID;

SharePoint Web 应用程序的有效名称(例如,MyOfficeApp1);或有效 SPWebApplication 对象的实例。

AllWebApplications: 指定为服务器场中的所有 SharePoint Web 应用程序部署新的 SharePoint 解决方案。

如果你需要强制部署此Solution,你可以使用-Force参数。

 
 
 
 possible errors:
 
Error Solution
Install-SPSolution : Admin SVC must be running in order to create deployment timer job. Open services.msc and start the service named SharePoint 2010 Administration.

Install-SPSolution : A deployment or retraction is already under way for the solution "webpartmanualdeployment.wsp", and only one deployment or retraction at a time is supported.

Go to Central Administration > System Settings > Manage farm solutions > Cancel / Retract the particular solution

部署Solution到指定的WebApplication中:

Install-SPSolution -Identity ilt.wsp -WebApplication http://sea:31996 -GACDeployment
 

我们也可使用–AllWebApplications参数来一次性从此Sharepoint Farm中的所有部署此Solution的Web Application中回收Solution.

执行此命令时,系统会提示: . “Are you sure?” ,你只需要确定即可执行操作。 
 

插曲, 当部署到指定Web Application 遇到错误的时候, 要建一个Dummy data, 制定DeploymentTarget 为 WebApplication: 参考: http://sharedpointers.blogspot.in/2011/03/deploying-solutions-to-specific-web.html

即:

  1. Double click the package
  2. Open the Advanced
  3. add an additional assembly (the solution for example) and mark Deployment Type "Web Application"

4. 升级已部署的Solution

Update-SPSolution -Identity ilt.wsp -LiteralPath "C:\ilt.wsp" -GACDeployment

5.卸载已部署的Solution

Uninstall-SPSolution -Identity ilt.wsp

Web Application 级别的:

Uninstall-SPSolution -Identity ilt.wsp -WebApplication http://sea:31996

6.移除已卸载的Solution

Remove-SPSolution -identity ilt.wsp

Possilble Errors:

Remove-SPSolution: The solution cannot be removed when a job is scheduled or running.

这里介绍一种方法来撤销这个部署的工作。

使用Stsadm -o enumdeployments 获取JobId,:

然后使用 stsadm -o canceldeployment -id JobId 来取消部署工作。

stsadm -o canceldeployment -id 2529c788-971c-46a3-b69f-a2a0a1fcc851      
 
 
 
eg:
//添加wsp包
Add-SPSolution C:\Users\akmii\Documents\Akmii.WuXiAppTec.Common.wsp

//deploy wsp 包

Install-SPSolution -Identity Akmii.WuXiAppTec.Common.wsp -GACDeployment –Force

//更新wsp包

Update-SPSolution -Identity Akmii.BMS.China.IHM.wsp -LiteralPath C:\WSP\Wsp-Xian\Akmii.BMS.China.IHM.wsp -GACDeployment -force

//强制删除
stsadm -o deletesolution -name akmii.museum.defines.wsp -override

//回收已经部署的Solution:
Uninstall-SPSolution –Identity MySharepointProject.wsp –WebApplication

//移除Solution
Remove-SPSolution –Identity MySharepointProject.wsp -Force

stsadm -o deploysolution -name Akmii.Museum.Web.wsp -immediate -allowGacDeployment -force

//备份还原站点集
 
Backup-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak   (注意:c盘Backup路径必须存在 )
 
Restore-SPSite http://server_name/sites/site_name -Path C:\Backup\site_name.bak   -Force (注意:站点集可以是新的站点也可以是原有的网站 )

PowerShell 发布farm solution的更多相关文章

  1. [Powershell]发布基于.NET Framework的WebAPI和Job控制台程序项目

    获取要发布的定时计划任务. 禁用和停止定时计划任务. 批量强制结束Job进程. 打印定时计划任务状态. 备份项目文件夹. 发布项目文件夹. 删除部署包. 启用定时计划任务. <# .NOTES ...

  2. Export Farm Solution wsp Files SharePoint 2007 and 2010

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")$farm = [Microsof ...

  3. PowerShell~发布你的mvc网站

    通过使用ps加上msbuild可以方便的编译你的.net应用程序,并且可以把它发布到你的磁盘上,部署非常方例! 我们在c盘添加一个hello网站,解决方案名是hello.sln,它的网站是hello. ...

  4. PowerShell实现基于SharePoint的网站HomePage Auto-Configure Solution

    Home Page Web Parts Auto-Configuration PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell写的一个自动化升级工具,此为三部自动化工具的 ...

  5. powershell 操作sharepoint命令集

    打开SharePoint 2013 Management Shell, and then run as administrator.执行如下命令 1. 添加wsp和安装Add-SPSolution - ...

  6. SharePoint 2013 Sandbox Solution

    昨天在写SharePoint EventReceiver的时候遇到一个问题,创建了一个local farm SharePoint solution,添加了一个ItemAdded(SPItemEvent ...

  7. SharePoint Add-in Model 介绍 - 引文(先导篇)

    1. SharePoint 平台 如果你已经很熟悉 SharePoint 平台,可跳过本章节. 1.1 SharePoint 是什么 在介绍 Add-in Model 之前,简要提一下 SharePo ...

  8. SharePoint 新特性及安装需知

    以下内容转自Kaneboy 大牛,但我在安装正式版的过程中发现一些问题,主要是.net 版本的问题,弄了我一个晚上,我在下面标出来了.我的安装环境是Windows server 2012 R2 关于详 ...

  9. Sharepoint学习笔记—习题系列--70-573习题解析 -(Q115-Q117)

    Question 115You create a timer job.You need to debug the timer job.To which process should you attac ...

随机推荐

  1. 我的docker全套流程例子

    本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: 下文是自己从搭建docker到docker里安装mysql到 ...

  2. Java经典编程题50道之九

    一个数如果恰好等于它的因子之和,这个数就称为"完数".例如6=1+2+3.编程找出1000以内的所有完数. public class Example09 {    public s ...

  3. LINUX signal 信号

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...

  4. mybatis与spring的整合(使用接口实现crud)

    本人刚刚接触mybatis,今天把它和spring整合起来用了一个上午==. 一开始是通过配置文件来配置,后来尝试用了一下注解,觉得mybatis的注解真的有点恶心...一大坨的,所以我还是建议使用配 ...

  5. Fantasia (Tarjan+树形DP)

    Time Limit: 1000 ms   Memory Limit: 256 MB Description 给定一张N个点.M条边的无向图 $G$ .每个点有个权值Wi. 我们定义 $G_i$ 为图 ...

  6. React——diff算法

    react的diff算法基于两个假设: 1.不同类型的元素会产生不同的树 2.通过设置key,开发者能够提示那些子组件是稳定的 diff算法 当比较两个树时,react首先会比较两个根节点,接下来具体 ...

  7. python更新数据库脚本两种方法

    最近项目的两次版本迭代中,根据业务需求的变化,需要对数据库进行更新,两次分别使用了不同的方式进行更新. 第一种:使用python的MySQLdb模块利用原生的sql语句进行更新 import MySQ ...

  8. 区块链 PoW 与 PoS 的纷争

    最近在研究区块链,可能会有一些非前端文章,感兴趣的可以关注关注哟. 有关注区块链的,肯定会经常看到这两个名词 -- PoW 与 PoS.但是很多人对他们的含义的理解存在很多偏差.那么他们的含义与区别是 ...

  9. 【java学习笔记】Properties

    Properties:可以持久化的映射,规定键和值的类型是String. Properties对象必须放到.properties文件中,其中properties文件默认为西欧编码,也因此不存储中文. ...

  10. probabilistic robotics_bayes filter

    贝叶斯滤波 执行测量后的后验概率: 执行测量前的先验概率: 执行测量后的后验概率推导 根据式2.23的推导方式 可推出 假定xt是complete,即xt可以完全决定测量结果,那么则有2.56式: 带 ...