PC Component Report Tool
This script is the first script i have made in Powershell. I orginally built this script to help a friend remotely identify the components in their gaming PC. Said friend had not touched the PC in so long that they no longer knew what was in the machine, nor what to upgrade to improve performance.
It's a simple and short script that gathers information about the host machine's components and the details regarding those components. The results are parsed to a .txt file, which is then saved to the machine's desktop. Which allows for simple and fast reviewing and sharing.
# PCReport.ps1
# Generates a PC hardware + storage health report on the current user's Desktop.
$outputPath = "$env:USERPROFILE\Desktop\PCReport.txt"
# Start report (overwrite if it already exists)
"PC Information Report - Generated on $(Get-Date)" | Out-File -FilePath $outputPath -Encoding UTF8
"==================================================" | Out-File -FilePath $outputPath -Append -Encoding UTF8
# ----------------------------
# System Information
# ----------------------------
"`n[System Information]" | Out-File -FilePath $outputPath -Append -Encoding UTF8
Get-ComputerInfo |
Select-Object CsManufacturer, CsModel, CsSystemType, WindowsProductName, WindowsVersion, OsBuildNumber, BiosBIOSVersion |
Format-List | Out-File -FilePath $outputPath -Append -Encoding UTF8
# ----------------------------
# CPU Information
# ----------------------------
"`n[CPU Information]" | Out-File -FilePath $outputPath -Append -Encoding UTF8
Get-CimInstance Win32_Processor |
Select-Object Name,
Manufacturer,
NumberOfCores,
NumberOfLogicalProcessors,
MaxClockSpeed,
CurrentClockSpeed,
L2CacheSize,
L3CacheSize,
ProcessorId |
Format-List | Out-File -FilePath $outputPath -Append -Encoding UTF8
# ----------------------------
# RAM Information (Summary)
# ----------------------------
"`n[Memory (RAM) Summary]" | Out-File -FilePath $outputPath -Append -Encoding UTF8
$cs = Get-CimInstance Win32_ComputerSystem
$os = Get-CimInstance Win32_OperatingSystem
[PSCustomObject]@{
TotalPhysicalMemory_GB = [math]::Round($cs.TotalPhysicalMemory / 1GB, 2)
FreePhysicalMemory_GB = [math]::Round(($os.FreePhysicalMemory * 1KB) / 1GB, 2)
TotalVisibleMemory_GB = [math]::Round(($os.TotalVisibleMemorySize * 1KB) / 1GB, 2)
} | Format-List | Out-File -FilePath $outputPath -Append -Encoding UTF8
# ----------------------------
# RAM Information (Modules / Sticks)
# ----------------------------
"`n[Memory (RAM) Modules]" | Out-File -FilePath $outputPath -Append -Encoding UTF8
Get-CimInstance Win32_PhysicalMemory |
Select-Object BankLabel,
Manufacturer,
PartNumber,
SerialNumber,
@{Name="Capacity_GB";Expression={[math]::Round($_.Capacity / 1GB, 2)}},
Speed,
ConfiguredClockSpeed,
FormFactor,
MemoryType |
Format-Table -AutoSize | Out-File -FilePath $outputPath -Append -Encoding UTF8
# ----------------------------
# Physical Disk Information
# ----------------------------
"`n[Physical Disk Information]" | Out-File -FilePath $outputPath -Append -Encoding UTF8
Get-PhysicalDisk |
Select-Object DeviceID, MediaType, Size, SerialNumber, HealthStatus, OperationalStatus |
Format-Table -AutoSize | Out-File -FilePath $outputPath -Append -Encoding UTF8
# ----------------------------
# Disk Drive Model + Interface (WMI)
# ----------------------------
"`n[Disk Drive Model & Interface]" | Out-File -FilePath $outputPath -Append -Encoding UTF8
Get-CimInstance Win32_DiskDrive |
Select-Object Model, InterfaceType, @{Name="Size_GB";Expression={[math]::Round($_.Size / 1GB, 2)}} |
Format-Table -AutoSize | Out-File -FilePath $outputPath -Append -Encoding UTF8
# ----------------------------
# SMART Failure Prediction
# ----------------------------
"`n[SMART Failure Prediction]" | Out-File -FilePath $outputPath -Append -Encoding UTF8
Get-CimInstance -Namespace root\wmi -ClassName MSStorageDriver_FailurePredictStatus |
Select-Object InstanceName, PredictFailure |
Format-Table -AutoSize | Out-File -FilePath $outputPath -Append -Encoding UTF8
# Footer
"`n==================================================" | Out-File -FilePath $outputPath -Append -Encoding UTF8
"Report saved to: $outputPath" | Out-File -FilePath $outputPath -Append -Encoding UTF8
Write-Output "Report saved to: $outputPath"
Skills and Knowledge Developed
- Powershell Scripting Fundamentals: Strengthened practical PowerShell scripting skills by developing and executing a functional script, transitioning from theoretical understanding to applied use.
- Troubleshooting and Debugging: Identified and resolved execution errors through log review, iterative testing, and targeted research of PowerShell behavior and syntax.
- Problem Solving Through Automation: Recognized a repetitive or inefficient task and implemented a scripted solution to improve reliability and reduce manual effort.
- Basic Data Handling in Scripts: Gained experience working with common data types and variables to store, process, and manipulate information within a PowerShell script.