Skip to content

Commit a6c2fcc

Browse files
author
jantari
committed
trim empty lines from BIOS update log output
1 parent 41a380d commit a6c2fcc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

private/Install-BiosUpdate.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
if ($installProcess.Err) {
2222
return $installProcess
2323
} else {
24+
[array]$LogMessage = if ($Log = Get-Content -LiteralPath "$PackageDirectory\winuptp.log" -ErrorAction SilentlyContinue) {
25+
$NonEmptyPredicate = [Predicate[string]] { -not [string]::IsNullOrWhiteSpace($args[0]) }
26+
27+
$LogFirstNonEmpty = [array]::FindIndex([string[]]$Log, $NonEmptyPredicate)
28+
if ($LogFirstNonEmpty -ne -1) {
29+
$LogLastNonEmpty = [array]::FindLastIndex([string[]]$Log, $NonEmptyPredicate)
30+
$Log[$LogFirstNonEmpty..$LogLastNonEmpty]
31+
}
32+
}
33+
2434
return [ExternalProcessResult]::new(
2535
$installProcess.Err,
2636
[BiosUpdateInfo]@{
@@ -31,7 +41,7 @@
3141
'ExitCode' = $installProcess.Info.ExitCode
3242
'StandardOutput' = $installProcess.Info.StandardOutput
3343
'StandardError' = $installProcess.Info.StandardError
34-
'LogMessage' = if ($Log = Get-Content -LiteralPath "$PackageDirectory\winuptp.log" -ErrorAction SilentlyContinue) { $Log } else { [String]::Empty }
44+
'LogMessage' = $LogMessage
3545
'Runtime' = $installProcess.Info.Runtime
3646
'ActionNeeded' = 'REBOOT'
3747
}

0 commit comments

Comments
 (0)