Share via


PowellShell script to backup WSP files

A lot of times we get stuck with a client environment where we need to perform a UAT refresh from PROD or create a test environment to support a client environment. We can create a replica by taking a full farm backup.

What we are creating is a replica of an environment manually and we do not have a WSP backup file or source code for the solution deployed in the farm. There is no option left for us to deploy the same solution into another environment without these two approaches.

For these kinds of situations, please use these below mentioned PowerShell command:

$farm = Get-SPFarm
$file = $farm.Solutions.Item("solution.wsp").SolutionFile
$file.SaveAs("c:\Solution.wsp")

This way, we can take a backup of the solution which is already deployed into the server farm and can re-use it in another environment.