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?
1 Answer
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
}