Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. $SitecoreInstanceUri = "https://helixsite.local"
  2. $Username = "admin"
  3. $Password = "b"
  4. $SitecorePackagePath = "C:inetpubwwwroothelixsite.localApp_DatapackagesHelix.Project.Website.Master.update"
  5.  
  6. #Create a new script session
  7. $session = New-ScriptSession -Username $Username -Password $Password -ConnectionUri $SitecoreInstanceUri
  8.  
  9. Write-Host "Installing Sitecore update package '$SitecorePackagePath' on '$SitecoreInstanceUri'"
  10.  
  11. $jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
  12. $package = $using:SitecorePackagePath
  13. Write-Log "Installing Sitecore update package '$package'"
  14. Install-UpdatePackage -Path $package -UpgradeAction Upgrade -InstallMode Install
  15. } -AsJob -Verbose
  16.  
  17. if (!$jobId) {
  18. Write-Host "No jobId was created. Please check if your Powershell Remoting is activated on the target instance '$SitecoreInstanceUri'"
  19. }
  20.  
  21. #doneScript is the script that gets executed every 5 seconds and checks the state of the executed script. It returns a custom PowerShell object with Name, IsDone and Status
  22. $doneScript = {
  23. $backgroundScriptSession = Get-ScriptSession -Id $using:jobId
  24. $isDone = $backgroundScriptSession -eq $null -or $backgroundScriptSession.State -ne "Busy"
  25. [PSCustomObject]@{
  26. "Name" = $backgroundScriptSession.Id
  27. "IsDone" = $isDone
  28. "Status" = "$($backgroundScriptSession.State)"
  29. }
  30. }
  31.  
  32. try {
  33. $keepRunning = $true
  34. while($keepRunning) {
  35. #Execute the doneScript and check the response.
  36. $response = Invoke-RemoteScript -Session $session -ScriptBlock $doneScript
  37. if($response -and $response.IsDone) {
  38. $keepRunning = $false
  39. Write-Host "Polling job $($response.Name). Status : $($response.Status)."
  40. Write-Host "Finished polling job $($id)."
  41. } else {
  42. Write-Host "Polling job $($response.Name). Status : $($response.Status)."
  43. Start-Sleep -Seconds 5
  44. }
  45. }
  46. } catch {
  47. if ($_.Exception.Message -eq "ScriptSessionNotFound,Cognifide.PowerShell.Commandlets.ScriptSessions.GetScriptSessionCommand") {
  48. Write-Host "Package installation triggered application pool recycling."
  49. }
  50. else
  51. {
  52. throw
  53. }
  54. }
  55.  
  56.  
  57. Write-Host "Sitecore update package installed."
  58. Stop-ScriptSession -Session $session
  59.  
  60. Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
  61. Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
  62. Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
  63. Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
  64. ... This keeps running for few minutes ...
  65. Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
  66. Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
  67. Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Available.
  68. Finished polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6.
  69. Sitecore update package installed.
  70.  
  71. Installing item '/sitecore/system/Settings/Forms/Submit Actions/Send E-mail'
  72. Installing item '/sitecore/system/Settings/Forms/Submit Actions/Submit Action'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement