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. 关于echarts 报错 初始化对象未定义

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  2. 捋一捋js面向对象的继承问题

    说到面向对象这个破玩意,曾经一度我都处于很懵逼的状态,那么面向对象究竟是什么呢?其实说白了,所谓面向对象,就是基于类这个概念,来实现封装.继承和多态的一种编程思想罢了.今天我们就来说一下这其中继承的问 ...

  3. EntityFrameWork连接多Db配置

    如题所示,EF作为微软主推的ORM工具,最新版本已经是7,说明有很多人在使用它做项目.在使用过程中,可能会连接不同的数据库,本文介绍的是连接SqlServer,MySql和SQLite三种,并且可以互 ...

  4. JVM性能监控与故障处理命令汇总(jps、jstat、jinfo、jmap、jhat、jstack)

    给一个系统定位问题的时候,知识.经验是关键基础,数据是依据,工具才是运用知识处理数据的手段 使用适当的虚拟机监控和分析的工具可以加快我们分析数据.定位解决问题的速度,本文主要介绍了几款服 务器上常用的 ...

  5. python使用

    1. ipython 打印所有的输出变量 from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast ...

  6. 论中国为什么造不出cpu和操作系统

    为什么呢?不是中国人不聪明. 而是中国缺乏科学研究的氛围 中国错过了计算机理论研究的黄金时期 中国人对计算机的了解是一支半解 中国缺乏对应的产业基础 中国缺乏计算机基础研究的氛围 计算机所运用的各种科 ...

  7. ActiveRecord的生命周期

    ActiveRecord的生命周期,通过方法重写和插入我们需要的业务逻辑来达到我们对程序的控制. 示例: 1,beforeSave() public function beforeSave($inse ...

  8. POJ - 3279 枚举 [kuangbin带你飞]专题一

    这题很经典啊,以前也遇到过类似的题--计蒜客 硬币翻转. 不过这题不仅要求翻转次数最少,且翻转方案的字典序也要最小. 解法:二进制枚举第一行的翻转方案,然后处理第二行,如果第二行的k列的上一列是黑色, ...

  9. SpringBoot CGLIB AOP解决Spring事务,对象调用自己方法事务失效.

    对于像我这种喜欢滥用AOP的程序员,遇到坑也是习惯了,不仅仅是事务,其实只要脱离了Spring容器管理的所有对象,对于SpringAOP的注解都会失效,因为他们不是Spring容器的代理类,Sprin ...

  10. C#访问修饰符(public,private,protected,internal,sealed,abstract)

    为了控件C#中的对象的访问权限,定义对象时可以在前面添加修饰符. 修饰符有五种:private(私有的),protected(受保护的),internal(程序集内部的),public(公开的),以及 ...