How to Deploy Multiple WSP Solutions using PowerShell in SharePoint?

Requirement: I have a bunch of WSP solution packages and had to add and deploy all of them to a cloned SharePoint environment.

Solution: Let’s bulk deploy all WSP solutions from a folder to SharePoint using PowerShell.

PowerShell script to bulk add Multiple solutions:

Deployment of WSP solutions is a common task for SharePoint administrators. And while there are many ways to do this, using PowerShell can be especially handy when you need to deploy multiple WSPs at once. This article will show you how to deploy multiple WSP solutions using PowerShell in SharePoint.

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

Function WaitForInsallation([string] $SolutionName)
{
        Write-Host -NoNewline "Waiting for deployment job to complete" $SolutionName "."
        $WSPSol = Get-SPSolution $SolutionName
        while($wspSol.JobExists)
        {
            sleep 2
            Write-Host -NoNewline "."
            $wspSol = Get-SPSolution $SolutionName
        }
        Write-Host "job Completed" -ForegroundColor green
}

Function Deploy-SPSolution ($WSPFolderPath)
{
    #Get all wsp files from the given folder
    $WSPFiles = Get-childitem $WspFolderPath | where {$_.Name -like "*.wsp"}

    #Iterate through each wsp and Add in to the solution store
    ForEach($File in $wspFiles)
    {
        $wsp = Get-SPSolution | Where {$_.Name -eq $File.Name}

        if($wsp -eq $null)
        {
            write-host "Adding WSP solution:"$File.Name
            Add-SPSolution -LiteralPath ($WspFolderPath + "\" + $file.Name)
        }
        else
        {
            write-host "solution already exists!"

        }
    }
}

try
{
        Deploy-SPSolution "C:\WSPFiles"
}
catch
{
    write-host $_.exception
} 

Once added to the SharePoint solution store, You can either deploy them to the targeted web applications/globally using PowerShell,

Install-SPSolution -Identity "Solution-Name" -Webapplication "Web-App-URL" -GacDeployment -Force

Tired of manually deploying each solution and would like to find a way to automate the process? Use the below script to deploy all solutions in one go:

#Deploy all installed solutions in the farm
Get-SPSolution | ForEach-Object { if (!$_.Deployed) {
 If ($_.ContainsWebApplicationResource -eq $False) {
    Install-SPSolution -Identity $_ -GACDeployment 
 }
else {
      Install-SPSolution -Identity $_ -AllWebApplications -GACDeployment 
   }
 }
}

Deploy SharePoint Solution Manually:

You can deploy from the SharePoint Central Administration site manually.

  • Navigate to SharePoint 2013/2016 Central Administration site.
  • Click on System Settings >> Manage Farm Solutions under Farm Management
  • Pick the relevant solution from the solution store
  • Click on “Deploy Solution” to start deploying the solution.
    sharepoint powershell deploy multiple solutions
    You may also have to activate necessary features that came through deployed solutions!

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “How to Deploy Multiple WSP Solutions using PowerShell in SharePoint?

  • This solution does not overwrite and update existing WSPs on sharepoint farm. Only non existing solutions will be deployed. For me, this did’nt help.

    Reply

Leave a Reply

Your email address will not be published.