Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a ps1 script that deploys all of my webparts. I started noticing an error (Error 503 service unavailable) after running Update-SPSolution. What is happening is that when I upgrade all my webparts, the application pools for all SharePoint web applications stop. It also takes about 12 minutes per web part to deploy (which seems like forever - it looks like it may be running them all in parallel). Could someone shed some light as to what the best way is to upgrade web parts using Update-SPSolution. Optimally, I would like my script to stop while it fully completes an upgrade on a particular web part, and then move on the next one when it is finished. Thoughts?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

SPSolution has a JobExists property that you can check in a while loop.

I would recommend throwing in a timeout in your while loop for good measure, to be safe:

Below is an example with Uninstall-SPSolution but it should work with upgrade as well, since both involve timer jobs

#the code below is typed in from memory so bear with me
$solution = Get-SPSolution | ?{$_.Name -eq "your solution name.wsp"}

#check if solution is deployed
if ( $solution.Deployed )
{
    Uninstall-SPSolution $solution.Name
    while ( $solution.JobExists )
    {
        write-host "."
        # TODO: insert check for timeout. something like if ( Date-Time -eq $timeoutDateTime)
        sleep 1
    }
    Remove-SPSolution $solution.Name
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.