Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am Looking for a way to detect if the a solution is deploying the following code does not seem to return "Deploying" like I see in central admin.

$wspID = Get-SPSolution -Identity 'mysolution.wsp';
Write-Host $wspID.Status;

running the above code repeatedly while deploying or retracting never returns "deploying" only things like "NotDeployed","GlobalDeployed", etc.

I want to determine it's deploying state so my code will wait until the previous solution is deployed.

share|improve this question

4 Answers 4

up vote 3 down vote accepted

There is no way to detect the deploy*ing* state of a solution, but you can check if the solution is deploy*ed*:

if($wspID.Deployed -eq $true){
}

If Deployed returns false wait a couple of seconds and try again.

share|improve this answer

The status only gives you basic info, but you can see what's going on by looking at the JobExists property, here's a but of a script doing that as part of a scripted deployment ($file is the wsp name)

$solution = Get-SPSolution -Identity:$file
while ($solution.JobExists -eq $true) {
    Write-Host '.' -NoNewline
    sleep -Seconds:1
    $solution = Get-SPSolution -Identity:$file
}
Write-Host
share|improve this answer

The best solution is to use the SPSolution.LastOperationResult and SPSolution.LastOperationDetails properties.

$solution = Get-SPSolution -Identity:$file
while ($solution.JobExists -eq $true) {
    Write-Host '.' -NoNewline
    sleep -Seconds:1
    $solution = Get-SPSolution -Identity:$file
}
$lastOperationResult = $solution.LastOperationResult
return ($lastOperationResult -eq [Microsoft.SharePoint.Administration.SPSolutionOperationResult]::DeploymentSucceeded)
share|improve this answer

Sharepoint creates job rather than deploy immediately, so you should check if the job has executed successfully. Take a look at this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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