15 49.0138 8.38624 1 0 4000 1 https://vladtalkstech.com 300 1
theme-sticky-logo-alt

How to Make sure a Solution is added before Activating it

3 Comments

When you deploy .wsp solutions and  you script your “Add-SpSolution  and Install-SpSolution”  in a row, PowerShell might throw an error because the Solution didn’t finish uploading on the farm before you try to activate it.

Here is a example of a do-while loop to make sure that the solution you are adding is fully uploaded and ready to be deployed before deploying it.

If you use farm solutions, use SPSolution instead of SpUserSolution

$mainurl = “http://vlad.test.loc”
Write-Host -ForegroundColor White ” – Adding and Installing vladsolution…” -NoNewline
Add-SPUserSolution -LiteralPath C:solutionsvladsolution.wsp -Site $mainurl
$ErrorActionPreference = “silentlycontinue”
do
{
Write-Host “.” -NoNewline -ForeGroundColor White;
Start-Sleep -Seconds 5;
try
{
$testsolution = Get-SPUserSolution -Identity  vladsolution .wsp -Site $mainurl
}
catch
{}
}while(!$testsolution);

$ErrorActionPreference = “stop”
Install-SPUserSolution -Identity  vladsolution .wsp -Site $mainurl
Write-Host -ForegroundColor GREEN “Done.” 
Write-Host 

Say Thanks if it helped 🙂

Previous Post
How to Check if SharePoint services are started and with what account they are running
Next Post
SharePoint sends emails to users but doesn’t send emails to Distribution Groups

3 Comments

  • June 5, 2013 at 2:40 pm
    John Jayaseelan

    Thanks..

    Reply
  • June 6, 2013 at 6:36 pm

    Thanks

    Reply
  • May 14, 2014 at 4:46 pm
    Jason

    Thanks

    Reply

Leave a Reply