Wait for a Solution to deploy with PowerShell – like execadmsvcjobs used to…

With previous versions of SharePoint is was usually possible to wait for a solution deployment to execute by running the STSADM –o execadmsvcjobs command.

With SharePoint 2010 and PowerShell, things can be done a little differently. The script snippet below can be used to wait for a Solution deployment to complete before the script continues and usefully shows deployment progress whilst waiting…

## Get the solution
$Solution = Get-SPSolution -identity $SolutionFileName

$lastStatus = ""

## loop whilst there is a Job attached to the Solution
while ($Solution.JobExists -eq $True)
{
    $currentStatus = $Solution.JobStatus
    if ($currentStatus -ne $lastStatus)
    {
            Write-Host "$currentStatus…" -foreground green -nonewline
            $lastStatus = $currentStatus
    }
    Write-Host "." -foreground green -nonewline
    sleep 1
}
## completed
Write-Host ""
Write-Host "     " $Solution.LastOperationDetails -foreground green

…the above can be used as the equivalent to the old stsadm –o execadmsvcjobs command.

I hope this helps…

Advertisements

One Response to Wait for a Solution to deploy with PowerShell – like execadmsvcjobs used to…

  1. Pingback: Simple PowerShell Deployment Scripts | SoftArtisans, Blogged

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: