Avilith – Scripts

System Health Report

Category: Diagnostics

Back to Scripts

Gathers hardware, software, update, network, and event log info and exports it as an HTML report for support or audit use.


$reportPath = "$env:USERPROFILE\Desktop\SystemHealthReport.html"
$html = @()
$html += "<html><head><title>System Health Report</title></head><body><h1>System Health Report</h1>"

$html += "<h2>Basic Info</h2><pre>"
$html += "Computer Name: $env:COMPUTERNAME"
$html += "`nUsername: $env:USERNAME"
$html += "`nOS: $((Get-CimInstance Win32_OperatingSystem).Caption)"
$html += "`nUptime: $([Math]::Round((Get-Date) - (gcim Win32_OperatingSystem).LastBootUpTime).TotalHours,2)) hrs"
$html += "</pre>"

$html += "<h2>Hardware</h2><pre>"
$html += "CPU: $((Get-CimInstance Win32_Processor).Name)"
$html += "`nRAM: $([math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1GB, 1)) GB"
$html += "</pre>"

$html += "<h2>Disk Usage</h2><pre>"
Get-PSDrive -PSProvider 'FileSystem' | ForEach-Object {
    $html += "$($_.Name): $($_.Used / 1GB -as [int])GB used / $($_.Free / 1GB -as [int])GB free"
}
$html += "</pre>"

$html += "<h2>IP Addresses</h2><pre>"
$html += (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {$_.IPAddress -ne "127.0.0.1"}).IPAddress -join "`n"
$html += "</pre>"

$html += "<h2>Recent Application Errors</h2><pre>"
$html += (Get-EventLog -LogName Application -EntryType Error -Newest 10 | Select-Object TimeGenerated, Source, Message | Out-String)
$html += "</pre>"

$html += "</body></html>"
$html | Out-File -FilePath $reportPath -Encoding UTF8

Write-Host "System health report saved to $reportPath" -ForegroundColor Green

        

Comments

Log in to leave a comment.