From 5a03788ca2a9fe2fa2bb1d3abbb3fcfd90de8123 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Fri, 14 Jun 2024 21:22:16 -0400 Subject: [PATCH] cleanup output for ticket comments --- Fix-WindowsHealth.ps1 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Fix-WindowsHealth.ps1 b/Fix-WindowsHealth.ps1 index f82d78d..935a79a 100644 --- a/Fix-WindowsHealth.ps1 +++ b/Fix-WindowsHealth.ps1 @@ -3,7 +3,10 @@ $tempFile = New-TemporaryFile $(sfc.exe /scannow) | Out-File $tempFile Set-Content -Path $tempFile -Value $(Get-Content -Path $tempFile -Encoding Unicode) -Encoding UTF8 $SFCOutput = Get-Content -Path $tempFile -$TicketComment = "SFC Output:`n" + ($SFCOutput -join "`n") +$TicketComment = "SFC Output:`n" +ForEach ( $line in $SFCOutput ) { + If ( $line -notmatch '^Verification \d{1,3}% complete\.$' ) { $TicketComment = $TicketComment + $line + "`n" } +} If ( $TicketID ) { Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Update" -Body $TicketComment -Hidden $true -DoNotEmail $true } Remove-Item $tempFile -Force -ErrorAction SilentlyContinue @@ -26,18 +29,14 @@ If ( IsWindowsVersion -ge "6.2" ) { $EndDISMRun = (Get-Date) # Extract results of DISM repair from system log and add them to this log - $TicketComment = "DISM Output:`n" Write-Output "Beginning Windows Component Store log data collection" Get-Content -Path "${Env:WinDir}\Logs\DISM\dism.log" | Select-String -Pattern '^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' | ForEach-Object { If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) { - $line = $_.Line - Write-Output $line - $TicketComment = $TicketComment + $line + "`n" + Write-Output $_.Line } } Write-Output "Completed Windows Component Store log data collection" - If ( $TicketID ) { Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Update" -Body $TicketComment -Hidden $true -DoNotEmail $true } } Else { Write-Output "Online image cleanup and restoration is only supported on Windows 8 and higher" }