Powershell, SharePoint Solutions, and Waiting for Deployment

When installing SharePoint solution packages using Powershell, you’ll need to wait for the solution to be installed after calling install-spsolution before you can enable features using enable-spfeature.  As a part of an automated script, you’d like for the script to know when the install is finished before continuing.

It’s surprisingly easy and can be accomplished with only a tiny bit of code:

That’s it!

On uninstall, the process is a little bit different as uninstall-spsolution does not return an instance of the solution.  You will want to grab the solution before you start the retraction:

This helps make for a much smoother install and uninstall process as you can be more certain that your solution is installed before executing code dependent on the solution (feature activation, solution removal, etc).

You may also like...

1 Response

  1. August 1, 2011

    […] Powershell, SharePoint Solutions, and Waiting for Deployment […]