Just provide the path of the folder where WSP is located and the function will add all the WSPs in Solution store.
Remove-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
function WaitForInsallation([string] $Name)
{
Write-Host -NoNewline "Waiting for deployment job to complete" $Name "."
$wspSol = get-SpSolution $Name
while($wspSol.JobExists)
{
sleep 2
Write-Host -NoNewline "."
$wspSol = get-SpSolution $Name
}
Write-Host "job ended" -ForegroundColor green
}
Function Deploy-SPSolution ($WspFolderPath)
{
$wspFiles = get-childitem $WspFolderPath | where {$_.Name -like "*.wsp"}
ForEach($file in $wspFiles)
{
$wsp = Get-SPSolution | Where{$_.Name -eq $file.Name}
if($wsp -eq $null)
{
write-host "Adding solution"
Add-SPSolution -LiteralPath ($WspFolderPath + "\" + $file.Name)
}
else
{
write-host "solution already exists"
}
}
}
try
{
Deploy-SPSolution "C:\EXPORTEDWSP"
}
catch
{
write-host $_.exception
}