$computerName = $env:COMPUTERNAME $reportPath = ".\Reports\Server-Health-$computerName.txt" if (!(Test-Path ".\Reports")) { New-Item -ItemType Directory -Path ".\Reports" | Out-Null } "Server Health Report - $computerName" | Out-File $reportPath "Generated: $(Get-Date)" | Out-File $reportPath -Append "" | Out-File $reportPath -Append "Operating System:" | Out-File $reportPath -Append Get-CimInstance Win32_OperatingSystem | Select-Object CSName, Caption, Version, LastBootUpTime | Format-List | Out-File $reportPath -Append "Disk Usage:" | Out-File $reportPath -Append Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | Select-Object DeviceID, @{Name="SizeGB";Expression={[math]::Round($_.Size / 1GB, 2)}}, @{Name="FreeGB";Expression={[math]::Round($_.FreeSpace / 1GB, 2)}} | Format-Table -AutoSize | Out-File $reportPath -Append "Stopped Services:" | Out-File $reportPath -Append Get-Service | Where-Object {$_.Status -eq "Stopped"} | Select-Object -First 20 Name, Status, StartType | Format-Table -AutoSize | Out-File $reportPath -Append Write-Host "Server health report created at $reportPath"