I'm using SPE to install the TDS .update
package file.
How do I get detailed installation log remotely in the script below?
Current PowerShell Script:
$SitecoreInstanceUri = "https://helixsite.local"
$Username = "admin"
$Password = "b"
$SitecorePackagePath = "C:\inetpub\wwwroot\helixsite.local\App_Data\packages\Helix.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
Current output is as below:
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.
Expected output:
I'm assuming remotely somehow we should be able to get installation logs as below.
Installing item '/sitecore/system/Settings/Forms/Submit Actions/Send E-mail'
Installing item '/sitecore/system/Settings/Forms/Submit Actions/Submit Action'
I was reading about the output type from Install-UpdatePackage
command is List<ContingencyEntry>
but I'm not sure how to read it remotely and display that in the output locally.
What I have tried so far:
I have tried below variation in the script above but it doesn't change anything in output in the console.
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
$package = $using:SitecorePackagePath
Write-Log "Installing Sitecore update package '$package'"
Install-UpdatePackage -Path $package -UpgradeAction Upgrade -InstallMode Install | ForEach-Object { Write-Verbose $_.ShortDescription; }
} -AsJob -Verbose