From 06b3169d6d884f1b5de13f046351d0f28c931cdf Mon Sep 17 00:00:00 2001 From: freddydk Date: Tue, 29 Nov 2022 20:02:08 +0100 Subject: [PATCH] x --- AppHandling/Sign-NavContainerApp.ps1 | 48 +++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/AppHandling/Sign-NavContainerApp.ps1 b/AppHandling/Sign-NavContainerApp.ps1 index 1d0386837..aca12fca9 100644 --- a/AppHandling/Sign-NavContainerApp.ps1 +++ b/AppHandling/Sign-NavContainerApp.ps1 @@ -66,7 +66,53 @@ try { TestPfxCertificate -pfxFile $sharedPfxFile -pfxPassword $pfxPassword -certkind "Codesign" Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Param($appFile, $pfxFile, $pfxPassword, $timeStampServer, $digestAlgorithm, $importCertificate) - + + function GetExtendedErrorMessage { + Param( + $errorRecord + ) + + $exception = $errorRecord.Exception + $message = $exception.Message + + try { + $errorDetails = $errorRecord.ErrorDetails | ConvertFrom-Json + $message += " $($errorDetails.error)`r`n$($errorDetails.error_description)" + } + catch {} + try { + if ($exception -is [System.Management.Automation.MethodInvocationException]) { + $exception = $exception.InnerException + } + $webException = [System.Net.WebException]$exception + $webResponse = $webException.Response + try { + if ($webResponse.StatusDescription) { + $message += "`r`n$($webResponse.StatusDescription)" + } + } catch {} + $reqstream = $webResponse.GetResponseStream() + $sr = new-object System.IO.StreamReader $reqstream + $result = $sr.ReadToEnd() + try { + $json = $result | ConvertFrom-Json + $message += "`r`n$($json.Message)" + } + catch { + $message += "`r`n$result" + } + try { + $correlationX = $webResponse.GetResponseHeader('ms-correlation-x') + if ($correlationX) { + $message += " (ms-correlation-x = $correlationX)" + } + } + catch {} + } + catch{} + $message + } + if ($importCertificate) { Import-PfxCertificate -FilePath $pfxFile -Password $pfxPassword -CertStoreLocation "cert:\localMachine\root" | Out-Null Import-PfxCertificate -FilePath $pfxFile -Password $pfxPassword -CertStoreLocation "cert:\localMachine\my" | Out-Null