Original

You are currently reviewing an older revision of this page.
Go to current version


Requirement


  • We need to export all our solutions from Test Environment to Production Farm.
  • We need to have a Solutions back up folder in both the farm

Environment


  • SharePoint 2010
  • PowerShell 2.0
  • Windows 2008 R2

Solution


We can achieve this using PowerShell
001
002
003
004
005
006
007
help Get-Location -Examples

help Set-Location -Examples

help Get-SPFarm -Examples

help New-Item -Examples

Code


001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
<#
.Synopsis
   SharePoint 2010 farm Solutions Back up
.DESCRIPTION
   This Script will help SP Admins to back up all WSP files in Folder as a backup.
   We can deploy directly from the back up or can be used as required.
.EXAMPLE
   Backup-SPSolutions -FolderPath C:\Temp -FolderName 'SPFarmSolutions'
.Contact
   chendrayan.exchange@hotmail.com
#>

function Backup-SPSolutions
{
    [CmdletBinding()]
    Param
    (
        # Provide Folder path to create a Back up folder
        [Parameter(Mandatory=$true,
                   helpmessage="Enter the valid path",
                   Position=0)]
        [System.String]
        $FolderPath,

        # name the back up folder eg: SPFarmSolutionsBackup
        [System.String]
        $FolderName
    )

    Begin
    {
        Write-Host "Backing Up SharePoint Farm Solutions..." -ForegroundColor Yellow 
        New-Item $FolderPath\$FolderName -ItemType Directory -Force  
        Set-Location $FolderPath\$FolderName
        Start-Sleep 2
         
    }
    
    Process
    {
        (Get-SPFarm).Solutions | %{$Solutions = (Get-Location).Path + â€œ\” + $_.Name; $_.SolutionFile.SaveAs($Solutions)}  
    }
    End
    {
        Write-Host "SharePoint Farm Solutions are backed up...." -ForegroundColor Yellow
        Invoke-Item $FolderPath\$FolderName
    }
}

Backup-SPSolutions -FolderPath C:\Temp -FolderName 'SPFarmSolutions'

Download


Download Link