backup

复制代码
# 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 yellow
Backup-SPSite $siteName  -Path $path -Force
Write-Host "Backup SPSite " $siteName "sucessful!" -foregroundcolor green
复制代码

restore

复制代码
# 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 yellow
Restore-SPSite $siteName  -Path $path -Force
Write-Host "Restore SPSite " $siteName "sucessful!" -foregroundcolor green
复制代码

deploy

复制代码
# 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 yellow
Add-SPSolution $solutionPortalPath
Add-SPSolution $solutionVendorPath
Write-Host "Solution Add Sucessful!" -foregroundcolor green

# Deploy Solution
Install-SPSolution –Identity SharePoint2010Solution.wsp –WebApplication http://myserver –GACDeployment

# Deploy  Sandbox Solution
Install-SPUserSolution –Identity SharePoint2010Solution.wsp     –WebApplication http://myserver  –GACDeployment

# Update Solution Package
Write-Host "Starting Update Solution,please waiting......" -foregroundcolor yellow
Update-SPSolution –Identity $solutionPortal –LiteralPath $solutionPortalPath –GacDeployment
Update-SPSolution –Identity $solutionVendor –LiteralPath $solutionVendorPath –GacDeployment
Write-Host "Solution Update Sucessful!" -foregroundcolor green

# Uninstall Solution Package
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication  http://myserver

# Remove Solution Package
Remove-SPSolution–Identity MySharePointSolution.wsp

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

posted on 2012-10-31 16:28  ilawrence  阅读(234)  评论(0编辑  收藏  举报