SharePoint 2010 PowerShell 系列 之 备份、还原、部署 .WSP

来源:互联网 发布:问卷数据分析 编辑:程序博客网 时间:2024/06/05 23:01

转:http://www.cnblogs.com/Fengger/archive/2012/08/24/2654093.html

PowerShell系列目录     

      最近在部署测试环境,就顺便把PowerShell 的部署命令了解一下,下面给详细讲解一下关于 PowerShell如何备份、还原及部署.WSP,有人会说,这样的操作通过管理中心可以很容易完成,为什么还要写命令呢?

   原因:界面操作是简单,但是执行的时间比较长,没有用命令速度快。命令一次写完后,以后直接拿来用就可以了,一次付出,终身获益......

第一:备份

复制代码
# Check to ensure Microsoft.SharePoint.PowerShell is loaded$Snapin = get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}if($Snapin -eq $null){    Write-host "Loading SharePoint Powershell Snapin"    Add-PSSnapin "Microsoft.SharePoint.Powershell"}$siteName = "http://SP:999"$path = "C:\site_name_999_test.bak"Write-Host "Starting backup SPSite " $siteName ",please waiting......" -foregroundcolor yellowBackup-SPSite $siteName  -Path $path -ForceWrite-Host "Backup SPSite " $siteName "sucessful!" -foregroundcolor green
复制代码

第二:还原

复制代码
# Check to ensure Microsoft.SharePoint.PowerShell is loaded$Snapin = get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}if($Snapin -eq $null){    Write-host "Loading SharePoint Powershell Snapin"    Add-PSSnapin "Microsoft.SharePoint.Powershell"}$siteName = "http://SP:666"$path = "C:\Project_201208231718.bak"Write-Host "Starting resotre SPSite " $siteName ",please waiting......" -foregroundcolor yellowRestore-SPSite $siteName  -Path $path -ForceWrite-Host "Restore SPSite " $siteName "sucessful!" -foregroundcolor green
复制代码

第三:部署WSP

复制代码
# Check to ensure Microsoft.SharePoint.PowerShell is loaded$Snapin = get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}if($Snapin -eq $null){    Write-host "Loading SharePoint Powershell Snapin"    Add-PSSnapin "Microsoft.SharePoint.Powershell"}$solutionPortalPath = "C:\aa.wsp"$solutionVendorPath = "C:\bb.wsp"$solutionPortal = "aa.wsp"$solutionVendor = "bb.wsp"# Add SPSolution Write-Host "Starting Add Solution,please waiting......" -foregroundcolor yellowAdd-SPSolution $solutionPortalPathAdd-SPSolution $solutionVendorPathWrite-Host "Solution Add Sucessful!" -foregroundcolor green# Deploy SolutionInstall-SPSolution –Identity SharePoint2010Solution.wsp –WebApplication http://myserver –GACDeployment# Deploy  Sandbox SolutionInstall-SPUserSolution –Identity SharePoint2010Solution.wsp     –WebApplication http://myserver  –GACDeployment# Update Solution PackageWrite-Host "Starting Update Solution,please waiting......" -foregroundcolor yellowUpdate-SPSolution –Identity $solutionPortal –LiteralPath $solutionPortalPath –GacDeploymentUpdate-SPSolution –Identity $solutionVendor –LiteralPath $solutionVendorPath –GacDeploymentWrite-Host "Solution Update Sucessful!" -foregroundcolor green# Uninstall Solution PackageUninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication  http://myserver# Remove Solution PackageRemove-SPSolution–Identity MySharePointSolution.wsp
复制代码

以上操作都比较简单,就没有写注释,相信大家一看就懂。

 

 

0 0
原创粉丝点击