Wait for WSP solution to deploy

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" } } }


One thought on “Wait for WSP solution to deploy

Add yours

  1. Hi 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: