Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
How to export a SharePoint Farm Solutions from a Solution Store using PowerShell - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

2013-06-10

Ah, my first blogpost on this community. 🙂

I use PowerShell a lot… with a development background, I found it not that hard to get used to it and once you get the hang of it, it gives you a lot of power and possibilities.

The script below gives you an easy way of extracting all farm solutions from a SharePoint solution store. I use it a lot when doing migration projects or assessments at customers. This ensures me that I have a copy of the WSP’s which are actually deployed.

.SYNOPSIS
Exports all farm solutions from a solutions store.
.DESCRIPTION
Exports all farm solutions from a solutions store.
.NOTES
File Name: Export-Solution.ps1
Version : 1.0
.PARAMETER OutputPath
Specifies the location where the exported solutions are saved.
.EXAMPLE
PS > .\Export-Solution.ps1 -OutputPath "c:\install\WSPExport"

Description
-----------
This script exports all existing solutions in the local solutions store
to c:\install\WSPExport.
#>
[CmdletBinding()]
param(
[parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false)]
[string]$OutputPath
)
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -EA SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
# Create the provided path if it doesn't exist
if (!(Test-Path -Path $OutputPath))
{
New-Item $OutputPath -ItemType directory >> $null
}

# Append a trailing backslash if needed
if (!$OutputPath.EndsWith("\",$false,$null))
{
$OutputPath += "\"
}

# Iterate over the solutions and save them to the provided output path
Write-Host "Exporting farm solutions to $OutputPath"
foreach ($solution in Get-SPSolution)
{
$id = $solution.SolutionId
$title = $solution.Name
$filename = $solution.SolutionFile.Name
Write-Host -NoNewline "Exporting '$title' to ...\$filename"
try
{
$solution.SolutionFile.SaveAs("$folder\$filename")
Write-Host -ForegroundColor Green " - OK"
}
catch
{
Write-Host -ForegroundColor Red " - error : $_"
}
}

 

(Visited 295 times, 1 visits today)

About the author 

Bart Kuppens

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.