Compare commits

..
2 Commits
Author SHA1 Message Date
dyoder f82ce18319 little cleanup
added some pauses to prevent spamming the end user
invokes Fix-WindowsHealth if necessary
2024-06-14 16:42:50 -04:00
dyoder 4c32fe1c1e allow for updating ticket comments 2024-06-14 16:41:02 -04:00
2 changed files with 48 additions and 10 deletions
+31 -5
View File
@@ -25,16 +25,42 @@ If ( -not (Test-Path $BSODReport) ) { Write-Output "BSOD report was not found: $
# Create ticket # Create ticket
Import-Module $env:SyncroModule -WarningAction SilentlyContinue Import-Module $env:SyncroModule -WarningAction SilentlyContinue
#$BSODReportContent = [System.IO.File]::ReadAllText($BSODReport) $BSODReportContent = Get-Content -Path $BSODReport
$BSODReportContent = Get-Content $BSODReport
$BSODReportContent = $BSODReportContent -join "`n"
$TicketSubject = 'BSOD on ' + $Env:COMPUTERNAME $TicketSubject = 'BSOD on ' + $Env:COMPUTERNAME
$TicketIssueType = 'Remote Support' $TicketIssueType = 'Remote Support'
$TicketStatus = 'New' $TicketStatus = 'New'
Try { Try {
$TicketComment = $BSODReportContent -join "`n"
$TicketData = Create-Syncro-Ticket -Subject $TicketSubject -IssueType $TicketIssueType -Status $TicketStatus $TicketData = Create-Syncro-Ticket -Subject $TicketSubject -IssueType $TicketIssueType -Status $TicketStatus
Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketData.ticket.id -Subject "Issue" -Body $BSODReportContent -Hidden $true -DoNotEmail $true $TicketID = $TicketData.ticket.id
Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Issue" -Body $TicketComment -Hidden $true -DoNotEmail $true
} }
Catch { Write-Error "Error creating ticket" ; Return } Catch { Write-Error "Error creating ticket" ; Return }
# Evaluate BSOD report for signs that Windows needs to be repaired # Update the ticket
Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Update" -Body "It looks like your computer crashed. I'll get this resolved as soon as possible." -Hidden $false -DoNotEmail $false
# Wait a bit
Start-Sleep -Seconds 120
# Setup providers for matching BSOD report content
$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 } {
$TicketComment = "I've analyzed the crash report and it indicates a problem with a Windows component. I'll repair the system now."
Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Update" -Body $TicketComment -Hidden $false -DoNotEmail $false
Create-Syncro-Ticket-TimerEntry -TicketIdOrNumber $TicketID -StartTime $StartAt -DurationMinutes $BillableTimeInMinutes -Notes $TimerNotes -UserIdOrEmail '' -ChargeTime $true
$FixWindowsHealth = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Fix-WindowsHealth.ps1'
Start-Sleep -Seconds 120
. $FixWindowsHealth
}
}
+15 -3
View File
@@ -3,14 +3,16 @@ $tempFile = New-TemporaryFile
$(sfc.exe /scannow) | Out-File $tempFile $(sfc.exe /scannow) | Out-File $tempFile
Set-Content -Path $tempFile -Value $(Get-Content -Path $tempFile -Encoding Unicode) -Encoding UTF8 Set-Content -Path $tempFile -Value $(Get-Content -Path $tempFile -Encoding Unicode) -Encoding UTF8
$SFCOutput = Get-Content -Path $tempFile $SFCOutput = Get-Content -Path $tempFile
$TicketComment = "SFC Output:`n" + ($SFCOutput -join "`n")
If ( $TicketID ) { Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Update" -Body $TicketComment -Hidden $true -DoNotEmail $true }
Remove-Item $tempFile -Force -ErrorAction SilentlyContinue Remove-Item $tempFile -Force -ErrorAction SilentlyContinue
# Examine $SFCOutput for integrity violations, if found make sure chkdsk runs at the next boot # Examine $SFCOutput for integrity violations, if found make sure chkdsk runs at the next boot
If ( $SFCOutput -contains 'Windows Resource Protection did not find any integrity violations.' ) { $ScheduleCheckDisk = $false } Else { $ScheduleCheckDisk = $true } If ( $SFCOutput -contains 'Windows Resource Protection did not find any integrity violations.' ) { $ScheduleCheckDisk = $false } Else { $ScheduleCheckDisk = $true }
# Run enhanced DISM for Windows 8 and higher endpoints # Run enhanced DISM for Windows 8 and higher endpoints
If ( IsWindowsVersion -ge "6.2" ) If ( IsWindowsVersion -ge "6.2" ) {
{
# Record start of DISM repair # Record start of DISM repair
$BeginDISMRun = (Get-Date) $BeginDISMRun = (Get-Date)
@@ -24,14 +26,18 @@ If ( IsWindowsVersion -ge "6.2" )
$EndDISMRun = (Get-Date) $EndDISMRun = (Get-Date)
# Extract results of DISM repair from system log and add them to this log # 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" 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})' | 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 { ForEach-Object {
If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) { If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) {
Write-Output $_.Line $line = $_.Line
Write-Output $line
$TicketComment = $TicketComment + $line + "`n"
} }
} }
Write-Output "Completed Windows Component Store log data collection" 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" } Else { Write-Output "Online image cleanup and restoration is only supported on Windows 8 and higher" }
@@ -39,4 +45,10 @@ Else { Write-Output "Online image cleanup and restoration is only supported on W
If ( $ScheduleCheckDisk ) { If ( $ScheduleCheckDisk ) {
Write-Output "Scheduling disk repair at next boot" Write-Output "Scheduling disk repair at next boot"
Start-Process "cmd.exe" -ArgumentList '/C echo y | chkdsk /F /R /X' -Wait Start-Process "cmd.exe" -ArgumentList '/C echo y | chkdsk /F /R /X' -Wait
$TicketComment = "Scheduled disk repair at next boot"
If ( $TicketID ) {
Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Update" -Body $TicketComment -Hidden $true -DoNotEmail $true
$TicketComment = "I've made some changes that will require you to restart your computer.`n`nWhenver you're ready, please restart your computer and allow it 30min to complete the startup process."
Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject "Update" -Body $TicketComment -Hidden $false -DoNotEmail $false
}
} }