Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $SitecoreInstanceUri = "https://helixsite.local"
- $Username = "admin"
- $Password = "b"
- $SitecorePackagePath = "C:inetpubwwwroothelixsite.localApp_DatapackagesHelix.Project.Website.Master.update"
- #Create a new script session
- $session = New-ScriptSession -Username $Username -Password $Password -ConnectionUri $SitecoreInstanceUri
- Write-Host "Installing Sitecore update package '$SitecorePackagePath' on '$SitecoreInstanceUri'"
- $jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
- $package = $using:SitecorePackagePath
- Write-Log "Installing Sitecore update package '$package'"
- Install-UpdatePackage -Path $package -UpgradeAction Upgrade -InstallMode Install
- } -AsJob -Verbose
- if (!$jobId) {
- Write-Host "No jobId was created. Please check if your Powershell Remoting is activated on the target instance '$SitecoreInstanceUri'"
- }
- #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
- $doneScript = {
- $backgroundScriptSession = Get-ScriptSession -Id $using:jobId
- $isDone = $backgroundScriptSession -eq $null -or $backgroundScriptSession.State -ne "Busy"
- [PSCustomObject]@{
- "Name" = $backgroundScriptSession.Id
- "IsDone" = $isDone
- "Status" = "$($backgroundScriptSession.State)"
- }
- }
- try {
- $keepRunning = $true
- while($keepRunning) {
- #Execute the doneScript and check the response.
- $response = Invoke-RemoteScript -Session $session -ScriptBlock $doneScript
- if($response -and $response.IsDone) {
- $keepRunning = $false
- Write-Host "Polling job $($response.Name). Status : $($response.Status)."
- Write-Host "Finished polling job $($id)."
- } else {
- Write-Host "Polling job $($response.Name). Status : $($response.Status)."
- Start-Sleep -Seconds 5
- }
- }
- } catch {
- if ($_.Exception.Message -eq "ScriptSessionNotFound,Cognifide.PowerShell.Commandlets.ScriptSessions.GetScriptSessionCommand") {
- Write-Host "Package installation triggered application pool recycling."
- }
- else
- {
- throw
- }
- }
- Write-Host "Sitecore update package installed."
- Stop-ScriptSession -Session $session
- Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
- Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
- Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
- Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
- ... This keeps running for few minutes ...
- Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
- Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Busy.
- Polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6. Status : Available.
- Finished polling job d8400253-9f9e-4718-89d5-0dd633bf3bf6.
- Sitecore update package installed.
- Installing item '/sitecore/system/Settings/Forms/Submit Actions/Send E-mail'
- Installing item '/sitecore/system/Settings/Forms/Submit Actions/Submit Action'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement