Trying to install a WSP solution via scripting and wanting to wait for the solution to be installed? This is a common scenario I’m facing quite a lot. Every time trying to find the script again, made me decide to blog about it.
This PowerShell script checks if the solution exists in the Solution Store and waits for it to finish its deployment job.
function WaitForSolutionToFinish([string]$SolutionFileName)
{
$solution = Get-SPSolution $SolutionFileName
if ($solution -eq $null) {
Write-Host " -solution '$SolutionFileName' not found in solution store"
}
if (!$solution.JobExists) {
Write-Host " -there are no solution jobs waiting"
}
else {
Write-Host -NoNewLine "Waiting for solution job"
$now = Get-Date
$timeout = (Get-Date).AddMinutes(5)
while ($solution.JobExists -and $now -le $timeout) {
Write-Host -NoNewLine "."
Start-Sleep -s 3
}
if (!$solution.JobExists) {
Write-Host " finished!"
}
else {
Write-Error "Waiting for solution job timed out! Check the Admin Timer Job status and ULS logs"
}
}
}
Like this:
Like Loading...
Posted by Bram de Jager on April 13, 2012
http://bramdejager.wordpress.com/2012/04/13/wait-for-wsp-solution-to-deploy/
Sander Schutten
/ April 17, 2012Hi Bram,
If you’re using the WaitForWSP-Script in a automated deployment of wsp’s, you might add a check to see if your wsp is correctly deployed to the site you expect it to be deployed to. I’ve seen situations in which the “WaitForWSP”-script will exit “succesfully”, but the deployment was in the error state. The rest of the automated deployment might depend on the correctly deployed wsp and fail.