From f77479c7b789feffd8675e6cbeadbda3bcdf5818 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Tue, 25 Jun 2024 16:07:23 -0400 Subject: [PATCH] lots of cleanup --- Create-NewTicketFromBSODAnalysis.ps1 | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Create-NewTicketFromBSODAnalysis.ps1 b/Create-NewTicketFromBSODAnalysis.ps1 index 9abb5f9..c8a1f9d 100644 --- a/Create-NewTicketFromBSODAnalysis.ps1 +++ b/Create-NewTicketFromBSODAnalysis.ps1 @@ -1,12 +1,12 @@ If ( Is64Bit ) { $BlueScreenView = $Global:ToolsDirectory + '\BlueScreenView-x64.exe' } Else { $BlueScreenView = $Global:ToolsDirectory + '\BlueScreenView-x86.exe' } -$BSODReport = $Global:OutputDirectory + '\BSODReport.txt' +If ( !(Test-Path $BlueScreenView) ) { Write-Error "File does not exist: ${BlueScreenView}" ; Return } # Remove existing BSOD report -If ( Test-Path $BSODReport ) { Remove-Item $BSODReport -Force -ErrorAction SilentlyContinue } +$BSODReport = $Global:OutputDirectory + '\BSODReport.txt' +If ( Test-Path $BSODReport ) { Write-Output "Deleting existing BSOD report: ${BSODReport}" ; Remove-Item $BSODReport -Force -ErrorAction SilentlyContinue } # Run BlueScreenView -If ( !(Test-Path $BlueScreenView) ) { Write-Error "File does not exist: ${BlueScreenView}" ; Return } -Start-Process $BlueScreenView -ArgumentList "/stext $BSODReport /sort ~1" -Wait +Start-Process $BlueScreenView -ArgumentList "/stext ${BSODReport} /sort ~1" -Wait # Wait for BSOD report For ($i = 0; $i -lt 1200; $i++) { @@ -33,19 +33,11 @@ $ProviderMicrosoft = 'Microsoft|Windows' # Get the provider data from the most recent BSOD $CulpritProvider = $BSODReportContent[12..13] -join '`n' -# Set the billable time -$BillableTimeInMinutes = 15 -$StartAt = (Get-Date).AddMinutes(-$BillableTimeInMinutes).ToString("o") - Switch ( $CulpritProvider ) { { $_ -match $ProviderMicrosoft } { New-TicketComment -Comment "I've analyzed the crash report and it indicates a problem with a Windows component. I'll repair the system now." - $TimeEntryNote = "Analysis indicates crash caused by Windows component(s). Scanning and repairing corruption in the system." - Create-Syncro-Ticket-TimerEntry -TicketIdOrNumber $TicketID -StartTime $StartAt -DurationMinutes $BillableTimeInMinutes -Notes $TimeEntryNote -UserIdOrEmail $TimeAttributedToUser -ChargeTime "true" - $FixWindowsHealth = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Fix-WindowsHealth.ps1' - Start-Sleep -Seconds 120 - . $FixWindowsHealth - If ( Test-Path $FixWindowsHealth ) { Remove-Item $FixWindowsHealth -Force -ErrorAction SilentlyContinue } + New-TicketTimerEntry -Comment "Analysis indicates crash caused by Windows component(s). Scanning and repairing corruption in the system." + Source-PSScript -ScriptName "Fix-WindowsHealth" } }