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. bzoj[1835][ZJOI2010]base 基地选址

    bzoj[1835][ZJOI2010]base 基地选址 标签: 线段树 DP 题目链接 题解 这个暴力DP的话应该很容易看出来. dp[i][j]表示造了i个通讯站,并且j是第i个的最小费用. \ ...

  2. 关于ruby -gem无法切换淘宝源

    ruby官网提供的 淘宝的gem源 不起作用 https://ruby.taobao.org/ taobao Gems 源已停止维护,现由 ruby-china 提供镜像服务 http://gems. ...

  3. Android Camera 摄像 demo

          google 在Android 5.0推出 Camera2 这个类,用于替换 Camera,但是Camera2要求android sdk 最低版本为 minSdkVersion = 21 ...

  4. nginx+tomcat单个域名及多个域名配置

    同步首发:http://www.yuanrengu.com/index.php/20171130.html 项目开发接近尾声,开始着手在生产环境部署项目,开发阶段部署项目都没用nginx.项目是采用S ...

  5. python进阶学习笔记(二)

    1.模块和包的概念 python的解决方案是把同名的模块放到不同的包中 1.1,导入模块 要使用一个模块,我们必须首先导入该模块.Python使用import语句导入一个模块.例如,导入系统自带的模块 ...

  6. 初步探究Android App API接口测试--实战

    一.Android App API接口测试 1.如何学好Android App API接口测试 postman可以用来实现API接口自动化测试,但是也有弊端,无法实现接口测试数据的参数化,为了达到接口 ...

  7. Sqlserver将数据从一张表插入到另一张表

    1.如果是整个表复制表达如下: insert into table1 select * from table2 2.如果是有选择性的复制数据表达如下: insert into table1(colum ...

  8. 一、Python介绍

    Python 是一门什么样的语言? python是一门动态解释性的强类型定义语言. 编程语言主要从以下几个角度为进行分类,编译型和解释型.静态语言和动态语言.强类型定义语言和弱类型定义语言,每个分类代 ...

  9. for、for in和while以及do while

    for循环:一般用在已知判断条件的循环; for(变量初始化;循环条件判断;循环后的执行){ 代码块 } //变量初始化可以省略,但是分号不能省.有多个的话用逗号隔开 //循环条件判断是true还是f ...

  10. Nginx HTTP模块指令

    alias 指令 该指令用于在url和系统路径之间的映射. location /a/{ alias /b/; } error_page 定义错误页面 error_page 404 /404.html; ...