0

I want to update multiple wsp solutions using powershell

Currently for every wsp file I have a powershell file with the below code

Update-SPSolution -Identity CustomWebparts.wsp -LiteralPath $PSScriptRoot\CustomWebparts.wsp -GACDeployment

I run the powershell and wait for deployment to happen and then run the next powershell script

How can I avoid this and deploy all wsp files in the folder using powershell?

1

Try the below script, I amend it for update solutions.

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 Update-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 "Solution already exists"
        }
        else
        {
            write-host "Updating solution"
            Update-SPSolution -identity $wsp -LiteralPath ($WspFolderPath + "\" + $file.Name) -GACDeployment

        }

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

}

Check more about this here Add multiple farm solutions using power shell (Not Deploy)

  • not sure why it didn't work I just updated the path inside try block – Vignesh Subramanian Sep 27 '16 at 13:08
  • what is the error? – Waqas Sarwar MVP Sep 27 '16 at 13:10
  • there were no errors I kept getting Updating solution message But when I went to the solution, the last operation time was not updated as it used to update when I do update solution individually – Vignesh Subramanian Sep 27 '16 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.