Handle looking for installer log before exit

This commit is contained in:
lawrencegripper
2024-12-02 14:36:15 +00:00
parent a0fc3d11c5
commit 0d3756a2ec
2 changed files with 19 additions and 40 deletions

View File

@@ -30,6 +30,10 @@ function Install-Binary {
.PARAMETER ExpectedSHA512Sum
The expected SHA512 sum of the binary. If specified, the binary's SHA512 sum is checked before installation.
.PARAMETER InstallerLogPath
The path to the log file which is produced when the installation fails. This can be used for debugging purposes.
This is only displayed when the installation fails.
.EXAMPLE
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Type EXE -InstallArgs ("/features", "+", "/quiet") -ExpectedSignature "A5C7D5B7C838D5F89DDBEDB85B2C566B4CDA881F"
#>
@@ -46,7 +50,8 @@ function Install-Binary {
[String[]] $ExtraInstallArgs,
[String[]] $ExpectedSignature,
[String] $ExpectedSHA256Sum,
[String] $ExpectedSHA512Sum
[String] $ExpectedSHA512Sum,
[String] $InstallerLogPath
)
if ($PSCmdlet.ParameterSetName -eq "LocalPath") {
@@ -122,6 +127,14 @@ function Install-Binary {
} else {
Write-Host "Installation process returned unexpected exit code: $exitCode"
Write-Host "Time elapsed: $installCompleteTime seconds"
if ($InstallerLogPath -and (Test-Path -Path $InstallerLogPath)) {
Write-Host "Searching for logs maching $InstallerLogPath pattern"
Get-ChildItem -Path $InstallerLogPath | ForEach-Object {
Write-Output "Found Installer Log: $InstallerLogPath"
Get-Content -Path $InstallerLogPath
}
}
exit $exitCode
}
} catch {