diff --git a/WindowsMaintenanceReport.ps1 b/WindowsMaintenanceReport.ps1 index 5e8110d..eedb911 100644 --- a/WindowsMaintenanceReport.ps1 +++ b/WindowsMaintenanceReport.ps1 @@ -114,11 +114,17 @@ function Write-Section { Write-Both $Writer $separator try { - & $Script 2>&1 | ForEach-Object { - $text = ($_ | Out-String -Width 240).TrimEnd() + $result = & $Script 2>&1 + $text = $result | Out-String -Width 240 - if (-not [string]::IsNullOrWhiteSpace($text)) { - Write-Both $Writer $text + if ([string]::IsNullOrWhiteSpace($text)) { + Write-Both $Writer '(no output)' + } + else { + $lines = $text.TrimEnd() -split "`r?`n" + + foreach ($line in $lines) { + Write-Both $Writer $line } } } @@ -126,7 +132,6 @@ function Write-Section { Write-Both $Writer ('ERROR: ' + $_.Exception.Message) } } - function Get-InstalledPrograms { $paths = @( 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',