<CharlieDigital/> Programming, Politics, and uhh…pineapples


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:

$sln = add-spsolution [YOUR_SOLUTION_PATH_HERE]

install-spsolution -identity [YOUR_SOLUTION_NAME_HERE] -gacdeployment

    echo "Deployment in progress..."

    start-sleep -s 5

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:

$sln = get-spsolution -identity [YOUR_SOLUTION_IDENTITY]

uninstall-spsolution -identity [YOUR_SOLUTION_IDENTITY] -confirm:$false -webapplication:$webAppName

echo "Started solution retraction..."

	echo " > Uninstall in progress..."
	start-sleep -s 5

remove-spsolution -identity [YOUR_SOLUTION_IDENTITY] -confirm:$false

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).

Posted by Charles Chen

Filed under: SharePoint Comments Off
  • vocal
  • trap
  • trance
  • techno
  • symphonic-rock
  • spain
  • soundtrack
  • soul
  • singer
  • score
  • rock
  • rnb
  • reggaeton
  • reggae
  • rap
  • punk
  • progressive
  • post-grunge
  • pop
  • other
  • new-audio
  • metalcore
  • lounge
  • latino
  • jazz
  • instrumental
  • indie
  • house
  • hip-hop
  • heavy-metal
  • hard-rock
  • funk
  • folk
  • electronic
  • dubstep
  • drum-and-bass
  • downtempo
  • deep-house
  • dance
  • country
  • club-house
  • classical
  • classic-rock
  • chillout
  • breakbeat
  • blues
  • ambient
  • alternative-rock