1

I am trying to create a PowerShell script for Adding and Deploying WSPs. I have multiple WSPs. Initially, I have to Retract and Remove existing WSPs, before I Add and Deploy them. As we know, the Retract is a time consuming activity. When I try to retract multiple WSPs using PowerShell script, how can I ensure that, it is done in a proper sequence, ensuring that it starts retraction of the 2nd WSP only after it completely retracts the 1st one, starts retraction of the 3rd only after it completely retracts the 2nd one and so on. If at all I add a pause or thread sleep, then how will I know the duration for the retraction of each. Can anyone please suggest, preferably with samples?

1 Answer 1

0

Retracting WSP actually creates a timer job under the hood. You can use 'do-while' statement instead of pausing the script after retracting your solution. The 'while' condition should check if the retracting job is still there. Here is the example:

Uninstall-SPSolution -Identity $MySolutionGUID -WebApplication "http://MyWebAppURL" -Confirm:$false

do {$solution = Get-SPSolution -Identity $MySolutionGUID} while ($solution.JobExists -eq $true)

This example works with solution ID ($MySolutionGUID variable), but you can change it to use solution name as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.