title: Powershell command for waiting one process to get completed
body: <p>I have power shell script which will perform multiple tasks like uninstalling,removing and again installing wsp solutions.I am facing an issue like the first process is taking too long time for uninstalling solution so that other process has to wait till the first action has to get completed fully.Now i am giving sleep time but it has some problem while different machines speed gets varies.. I also aware about calling notepad like an external function but i dont want that has to happen here.Apart from that any solutions are availabe like I need to wait for first process to get complete before starting the second process.</p>
  
  <pre><code>$InstallDIR = "F:\new\source\UpdatedWSPFiles"
  $Dir = get-childitem $InstallDIR -Recurse
  $WSPList = $Dir | where {$_.Name -like "*.wsp*"}
  Foreach ($wsp in $WSPList )
  {
  $WSPFullFileName = $wsp.FullName
  $WSPFileName = $wsp.Name
  try
  {
  Write-Host -ForegroundColor White -BackgroundColor Blue "Working on $WSPFileName"
  Write-Host -ForegroundColor Green "Retracting Solution"
  Uninstall-SPSolution -AllWebApplications -Identity "$WSPFileName" -Confirm:$false 
  sleep 100
  
  Write-Host -ForegroundColor Green "Removing Solution from farm"
  Remove-SPSolution -Identity "$WSPFileName" -Confirm:$false -Force
  sleep 60
  
  Write-Host -ForegroundColor Green "Adding solution to farm"
  Add-SPSolution "$WSPFullFileName"  -Confirm:$false 
  sleep 60
  }
  </code></pre>