How to take a Backup of WSP in a SharePoint server using PowerShell Script

Introduction 
 
In this blog, I will be demonstrating how to take a backup of WSP in a SharePoint server using PowerShell Script.
 
Windows SharePoint Solution (WSP) files are CAB files including all set of features and functionality, site definitions, services, and other required custom availability. WSP files can be reused and easily deployed to other SharePoint farms, in the case that we have not configured the web application URL under the same WSP.
 
Below are the steps to create a backup file of the existing solution using SharePoint PowerShell:
 
• Login to the server and run the SharePoint PowerShell management Tool as Administrator.
• Once PowerShell has opened, copy the below script and hit enter
  1. $farm = Get-SPFarm  
  2.   
  3. $file = $farm.Solutions.Item("Solutionname.wsp").SolutionFile  
  4.   
  5. $file.SaveAs("c:\Solutionname.wsp")  
Once the above command has executed, we can get the WSP file on the given file.